Skip to content

Instantly share code, notes, and snippets.

@paulormart
Last active December 2, 2021 22:57
Show Gist options
  • Save paulormart/8781f464d7ac0545ed4d488e46bbd71e to your computer and use it in GitHub Desktop.
Save paulormart/8781f464d7ac0545ed4d488e46bbd71e to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# > make a file executable
# chmod +x ./polkadot-node-update.sh
DIRNAME="/polkadot/bin"
FILENAME="$DIRNAME/polkadot"
ARTIFACTS="./artifacts"
if [ ! -d "$ARTIFACTS" ]
then
mkdir -p $ARTIFACTS
fi
read -p "Enter the Polkadot binary version that you would like to update (e.g.: 0.9.12): " INPUT_VERSION
if [ "$INPUT_VERSION" = "" ]; then
INPUT_VERSION="0.9.12"
fi
URI="https://github.com/paritytech/polkadot/releases/download/v$INPUT_VERSION/polkadot"
URI_SHA256="https://github.com/paritytech/polkadot/releases/download/v$INPUT_VERSION/polkadot.sha256"
wget $URI -P $ARTIFACTS && wget $URI_SHA256 -P $ARTIFACTS
if sha256sum -c $ARTIFACTS/polkadot.sha256 2>&1 | grep -q 'OK'
then
if [ ! -d "$DIRNAME" ]
then
mkdir -p $DIRNAME
fi
if [[ -f "$FILENAME" ]]
then
mv "$FILENAME" "$FILENAME.backup"
fi
rm $ARTIFACTS/polkadot.sha256
chmod +x $ARTIFACTS/polkadot
mv $ARTIFACTS/polkadot "$FILENAME"
echo "** polkadot v$INPUT_VERSION successfully downloaded and verified $FILENAME **"
sudo systemctl restart polkadot-node.service
echo "** polkadot-node.service restarted **"
else
echo "Error: SHA256 doesn't match!"
rm "$ARTIFACTS/*"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment