SHARE
TWEET

Untitled

a guest Jun 25th, 2014 26 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # restart_node_number.sh -- v0.0.1 -- moocowmoo
  4. # restart a numbered masternode
  5. # - depends on:
  6. #   .ssh/config entries (drk-1, drk-2, etc.)
  7. #   confs and wallets named:
  8. #    darkcoin.conf.hd-0p-0-$N
  9. #    wallet.dat.hd-0p-0-$N
  10. #   where $N is an integer
  11. #
  12. # usage: ./restart_node_number.sh 1 [walletpassphrase]
  13. #
  14. # I do this with environment variables as:
  15. # $  export P='mywalletpassphrase'
  16. # (note the extra space at the beginning, keeps entry out of history)
  17. # $ ./restart_node_number.sh 1 $P
  18.  
  19. case $1 in
  20.     ''|*[!0-9]*) echo usage $0 node_number; exit ;;
  21.     *) ;;
  22. esac
  23.  
  24. echo "stopping local daemon"
  25. darkcoind stop 2>/dev/null;
  26. echo "waiting 2 seconds for daemon to shutdown"
  27. sleep 2;
  28.  
  29. N=$1;
  30. P=$2;
  31.  
  32. rm darkcoin.conf wallet.dat ;
  33. ln -s darkcoin.conf.hd-0p-0-$N darkcoin.conf ;
  34. ln -s wallet.dat.hd-0p-0-$N wallet.dat ;
  35.  
  36. echo "starting local daemon"
  37. darkcoind &
  38. echo "waiting 10 seconds for daemon to initialize..."
  39. sleep 10;
  40.  
  41. BALANCE=$(darkcoind getbalance);
  42.  
  43. if [ "$BALANCE" \< 1000 ] ; then
  44.         echo masternode address has insufficient funds. $BALANCE DRK. exiting;
  45.         exit;
  46. fi
  47.  
  48. echo "local wallet balance checks out: $BALANCE"
  49.  
  50.  
  51. # get wallet passphrase if not supplied
  52.  
  53. if [ -z "$P" ] ; then
  54.         read -s -p 'enter wallet password: ' P
  55.         echo;
  56. fi
  57.  
  58. # check wallet passphrase before embarking
  59.  
  60. SUCCESS=$(darkcoind walletpassphrase $P 60 2>&1 );
  61.  
  62. if [[ $SUCCESS =~ 'Error' ]] ; then
  63.         echo invalid password. exiting.
  64.         exit;
  65. fi
  66.  
  67. echo "local wallet password checks out"
  68.  
  69. echo "shutting down remote daemon"
  70.  
  71. ssh drk-$N 'darkcoind stop;'
  72.  
  73. echo "waiting 5 seconds for daemon to shutdown..."
  74. sleep 5;
  75.  
  76. echo "starting remote daemon"
  77. ssh drk-$N 'darkcoind </dev/null >/dev/null 2>&1 &'
  78.  
  79. echo "waiting 5 seconds for daemon to startup..."
  80. sleep 5;
  81.  
  82. SUCCESS=$(darkcoind masternode start $P 2>&1 );
  83.  
  84. echo $SUCCESS;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top