#!/bin/bash
# simple masternode updater to newest version
# Prerequisites: screen, git
function fullupdate(){
echo -e "\n"
echo "**********************************"
echo "removing old dash github directory"
echo "**********************************"
echo -e "\n"
rm -rf dash
sleep 1
echo -e "\n"
echo "******************************************"
echo "Getting new dash github version to compile"
echo "******************************************"
echo -e "\n"
git clone
https://github.com/dashpay/dash.git
sleep 5
echo -e "\n"
echo "****************************"
echo "configuring new build step 1"
echo "****************************"
echo -e "\n"
cd dash
./autogen.sh
sleep 1
echo -e "\n"
echo "****************************"
echo "configuring new build step 2"
echo "****************************"
echo -e "\n"
./configure --with-incompatible-bdb --disable-tests --without-gui
sleep 1
echo -e "\n"
echo "***************"
echo "start compiling"
echo "***************"
echo -e "\n"
make
echo -e "\n"
echo "*******************************"
echo "stop & backup the running dashd"
echo "*******************************"
echo -e "\n"
cd ..
./dash-cli stop
sleep 10
cp -n dashd dashdBACKUP
rm dashd
cp -n ./dash/src/dashd .
cp -n ./dash/src/dash-cli .
echo -e "\n"
echo "*********************"
echo "starting new version!"
echo "*********************"
echo -e "\n"
clear
./dashd -shrinkdebugfile
echo -e "\n"
echo "********************************************************************"
echo "DONE! remember to check if you need to start it from the hot wallet!"
echo "********************************************************************"
echo -e "\n"
}
clear
echo -e "\n"
echo "*****************************************************************************************************************"
echo -e "\n"
echo 'please choose on of the following options:'
echo -e "\n"
echo "1: keep this terminal open during the update (Note: closing this terminal will stop the full process of updating!)"
echo "2: Do the update in the backgroud using the 'screen' command (After this you can close this terminal)"
echo "3: exit"
echo -e "\n"
echo "*****************************************************************************************************************"
echo -e "\n"
echo "Your choice:"
read n
case $n in
1) fullupdate;;
2) echo "not working yet";;
3) exit;;
*) exit;;
esac