Last active
March 3, 2021 22:23
-
-
Save hirishh/ccf40d50e123ae59502b7a31ce6c8fcc to your computer and use it in GitHub Desktop.
Polkadot updater
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
get_latest_release () { | |
curl --silent "https://api.github.com/repos/paritytech/polkadot/releases/latest" | # Get latest release from GitHub api | |
grep '"tag_name":' | # Get tag line | |
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value | |
} | |
V=`get_latest_release` | |
SERVICE="polkadot-validator" | |
echo "#######################################" | |
echo "# Polkadot Updater #" | |
echo "#######################################" | |
echo | |
read -p "Do you want to upgrade to $V (y/N)? " -n 1 -r | |
echo | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
echo "Downloading to $HOME/polkadot.$V..." | |
curl -sL https://github.com/paritytech/polkadot/releases/download/$V/polkadot -o $HOME/polkadot.$V | |
chmod +x $HOME/polkadot.$V | |
echo "Stopping the service $SERVICE.service..." | |
sudo systemctl stop $SERVICE.service | |
echo "Linking the new version to $HOME/polkadot..." | |
rm $HOME/polkadot | |
ln -s $HOME/polkadot.$V $HOME/polkadot | |
echo "Starting the service $SERVICE.service..." | |
sudo systemctl start $SERVICE.service | |
echo "Printing the status now." | |
sudo systemctl status $SERVICE.service --no-pager | |
echo -e "\n\nUse 'sudo journalctl -f -u $SERVICE' to check the logs." | |
echo -e "\nPolkadot updated to $V. Byez!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment