-
-
Save chaeplin/d86f5085a5991b23f71303f0dd86c34d to your computer and use it in GitHub Desktop.
12-1-install-update.sh
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/sh | |
########## REQUIRED PACKAGES | |
#sudo apt-get install wget jq | |
########## PLEASE SET OS FOR UPDATE | |
VERSION="linux64" | |
#VERSION="linux32" | |
#VERSION="RPi2" | |
########## PLEASE SET DESTINATION PATH | |
DASH_PATH=~/.dashcore | |
################################################## | |
mkdir -p ~/.dashcore | |
cd "$DASH_PATH" | |
echo "Scenario \033[33m$VERSION\033[0m" | |
CONTENT=$(wget https://www.dashninja.pl/dashninja-latestversion.json -q -O -) | |
DASH_VERSION=$(echo "$CONTENT" | jq -M -r '.version.string') | |
if [ -f ./dash-cli ]; then | |
YOUR_RAW_VERSION=$(./dash-cli getinfo | jq -M -r '.version') | |
YOUR_VERSION="0" | |
for c in 1 3 5 | |
do | |
PART=$(echo "$YOUR_RAW_VERSION" | cut -c $((c))-$((c+1))) | |
PART=$((PART+0)) | |
YOUR_VERSION="$YOUR_VERSION.$PART" | |
done | |
fi | |
echo "Your version \033[33m$YOUR_VERSION\033[0m" | |
if [ "$YOUR_VERSION" = "$DASH_VERSION" ] | |
then | |
echo "Last version \033[33m$DASH_VERSION\033[0m" | |
exit; | |
fi | |
echo "New version available \033[33m$DASH_VERSION\033[0m" | |
URL="https://www.dash.org/binaries/dashcore-$DASH_VERSION-$VERSION.tar.gz" | |
FILE=${URL##*/} | |
DIR=${FILE%.tar.gz} | |
echo "Download \033[33m$FILE\033[0m" | |
wget -q "$URL" | |
echo "Extract \033[33m$FILE\033[0m" | |
EXTRACTED_PATH=$(tar xzvf "$FILE" | sed -n 1p) | |
echo "\033[0;31mStop\033[0m MasterNode" | |
./dash-cli stop > /dev/null 2>&1 | |
sleep 15 | |
killall -9 dashd dash-shutoff > /dev/null 2>&1 | |
sleep 1 | |
echo "Replace files" | |
rm dashd dash-cli > /dev/null 2>&1 | |
mv "${EXTRACTED_PATH}bin/dashd" . | |
mv "${EXTRACTED_PATH}bin/dash-cli" . | |
chmod 755 dashd dash-cli | |
echo "Remove temporary files" | |
rm "$FILE" | |
rm -rf "$EXTRACTED_PATH" | |
rm peers.dat debug.log db.log > /dev/null 2>&1 | |
echo "\033[0;31mStart\033[0m MasterNode" | |
./dashd & | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please check my fork.
Added:
Unfortunately i can't currently open a pull request on a Gist.