Created
December 21, 2021 00:41
-
-
Save paulormart/db7474ffb988db3455995fe95dd1bb45 to your computer and use it in GitHub Desktop.
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 | |
# | |
# > 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 the polkadot binary version to update (e.g.: 0.9.14) from the first positional | |
# argument (e.g. ./polkadot_node_update.sh 0.9.14) | |
INPUT_VERSION = $1 | |
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