diff --git a/bin/admin.sh b/bin/admin.sh index a3c282349daea4c25b2f7276c9e2b61e24cfbe45..035393395b9f6e5d827deffb2b881085b737ff7f 100755 --- a/bin/admin.sh +++ b/bin/admin.sh @@ -22,60 +22,63 @@ function modefilter function admin_syncmode { -echo "Available synchronization modes:" -echo " full : verify all blocks and all transactions since genesis (most secure)" -echo " fast : verify all blocks but not all transactions (faster than full, but less certain)" -echo " light: Makes this node into a light node which downloads almost" -echo " nothing, but relies on fast and full nodes in the network" -echo " to answer it's requests. This is the fastest and uses least" -echo " local resources, but outsources all trust to another node." -echo "Default mode is fast, because for many, it is a healthy compromise" -echo "between speed and paranoia. You can change the setting, according to" -echo "your needs." + echo "Available synchronization modes:" + echo " full : verify all blocks and all transactions since genesis (most secure)" + echo " fast : verify all blocks but not all transactions (faster than full, but less certain)" + echo " light: Makes this node into a light node which downloads almost" + echo " nothing, but relies on fast and full nodes in the network" + echo " to answer it's requests. This is the fastest and uses least" + echo " local resources, but outsources all trust to another node." + echo "Default mode is fast, because for many, it is a healthy compromise" + echo "between speed and paranoia. You can change the setting, according to" + echo "your needs." -mode=$( cat ${BFANODEDIR}/syncmode 2>/dev/null || true ) -mode=${mode:-${defaultsyncmode}} -orgmode=$mode -modefilter -echo "Your current mode is set to ${mode}" -killed=0 -mode= - -echo -while [ -z "${mode}" ] -do - read -p "Which mode do you wish? : " mode + mode=$( cat ${BFANODEDIR}/syncmode 2>/dev/null || true ) + mode=${mode:-${defaultsyncmode}} + orgmode=$mode modefilter -done -echo $mode > ${BFANODEDIR}/syncmode -if [ "$orgmode" = "fast" -a "$mode" = "full" ] -then - echo "You increased your paranoia level. The proper thing to do now," - echo "would be to delete your version of what you synchronized with" - echo "fast mode, and revalidate everything in the entire blockchain." - echo "This probably takes quite a long time and also requires downloading" - echo "all blocks from the entire blockchain again." - yesno n "Do you wish to delete all downloaded blocks and resynchronize?" - if [ "$REPLY" = "y" ] + echo "Your current mode is set to ${mode}" + killed=0 + mode= + + echo + while [ -z "${mode}" ] + do + read -p "Which mode do you wish? : " mode + modefilter + done + echo "Remembering your choice." + echo $mode > ${BFANODEDIR}/syncmode + if [ "$orgmode" = "fast" -a "$mode" = "full" ] then - if [ -r "${BFANODEDIR}/geth.pid" ] + echo "You increased your paranoia level. The proper thing to do now," + echo "would be to delete your version of what you synchronized with" + echo "fast mode, and revalidate everything in the entire blockchain." + echo "This probably takes quite a long time and also requires downloading" + echo "all blocks from the entire blockchain again." + yesno n "Do you wish to delete all downloaded blocks and resynchronize?" + if [ "$REPLY" = "y" ] then - pid=$( cat ${BFANODEDIR}/geth.pid ) - kill -0 $pid 2>/dev/null && - echo "Killing running geth." && - killed=1 - while ! kill $pid 2>/dev/null - do - sleep 1 - done + if [ -r "${BFANODEDIR}/geth.pid" ] + then + pid=$( cat ${BFANODEDIR}/geth.pid ) + kill -0 $pid 2>/dev/null && + echo "Killing running geth." && + killed=1 + while ! kill $pid 2>/dev/null + do + sleep 1 + done + fi + rm -fr ${BFANODEDIR}/geth/chainstate ${BFANODEDIR}/geth/lightchainstate + geth --cache 0 --datadir ${BFANODEDIR} init ${BFAHOME}/src/genesis.json + test $killed -eq 1 && + echo && + echo "The startup.sh should restart your geth shortly." fi - rm -fr ${BFANODEDIR}/geth/chainstate ${BFANODEDIR}/geth/lightchainstate - geth --cache 0 --datadir ${BFANODEDIR} init ${BFAHOME}/src/genesis.json - test $killed -eq 1 && - echo && - echo "The startup.sh should restart your geth shortly." + else + echo "No further action taken." fi -fi } function admin_bootnode