securenodes
Zend Upgrade Script for both Legacy CPU and APT repo installations
Hi there,
I trust everyone is well.
I have decided to create an update script that will check to see if the CPU instruction set your node instance has can either run the APT repo install or if it needs to install the legacy CPU binaries.
The script will grab the latest version number from Github and then check the CPU instruction set. It will then install the correct binary for your CPU type and it will also update and upgrade any APT packages that are installed. Finally it will reboot the instance.
Please see the bash script below:
#!/usr/bin/env bash
# Get current Zend version
zendVer=`curl --silent "https://api.github.com/repos/HorizenOfficial/zen/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed -E 's/^.{1}//'`
echo $zendVer
# Get CPU instruction set
if ( grep -q "adx" /proc/cpuinfo && grep -q "bmi2" /proc/cpuinfo ) then
cpuType="Supported"
else
cpuType="Legacy"
fi
echo $cpuType
case $cpuType in
"Legacy")
wget "https://github.com/HorizenOfficial/zen/releases/download/v"$zendVer"/zen-"$zendVer"-legacy-cpu-amd64.deb"
sudo dpkg --install "zen-"$zendVer"-legacy-cpu-amd64.deb"
rm -rf "zen-"$zendVer"-legacy-cpu-amd64.deb"
;;
"Supported")
echo 'deb https://HorizenOfficial.github.io/repo/ '$(lsb_release -cs)' main' | sudo tee /etc/apt/sources.list.d/zen.list
sudo apt-get update
sudo apt-get install zen -y
;;
esac
# Update apt applications
sudo apt update && sudo apt upgrade -y
sudo reboot
I hope that you find this script useful. If you have any questions you can hit me up on the Horizen discord.