Skip to content

Instantly share code, notes, and snippets.

@TomaszWaszczyk
Forked from hirishh/polkadot_updater.sh
Created March 3, 2021 22:23
Show Gist options
  • Save TomaszWaszczyk/316cf8f5b20f06d094c19f9d1b5ce275 to your computer and use it in GitHub Desktop.
Save TomaszWaszczyk/316cf8f5b20f06d094c19f9d1b5ce275 to your computer and use it in GitHub Desktop.
Polkadot updater
#!/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