Advertisement
Guest User

v2_install.sh

a guest
Apr 21st, 2018
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.55 KB | None | 0 0
  1. #!/bin/bash
  2. clear
  3.  
  4. # Set these to change the version of Bulwark to install
  5. TARBALLURL="https://github.com/bulwark-crypto/Bulwark/releases/download/1.2.4/bulwark-1.2.4.0-linux64.tar.gz"
  6. TARBALLNAME="bulwark-1.2.4.0-linux64.tar.gz"
  7. BOOTSTRAPURL="https://github.com/bulwark-crypto/Bulwark/releases/download/1.2.4/bootstrap.dat.zip"
  8. BOOTSTRAPARCHIVE="bootstrap.dat.zip"
  9. BWKVERSION="1.2.4.0"
  10.  
  11. # Check if we are root
  12. if [ "$(id -u)" != "0" ]; then
  13.    echo "This script must be run as root." 1>&2
  14.    exit 1
  15. fi
  16.  
  17. # Check if we have enough memory
  18. if [[ `free -m | grep Mem | cut -d " " -f 12` -lt 2024 ]]; then
  19.     fallocate -l 2G /swapfile
  20.     chmod 600 /swapfile
  21.     mkswap /swapfile
  22.     echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab
  23. fi
  24.  
  25. # Check if we have enough disk space
  26. if [[ `df -k --output=avail / | tail -n1` -lt 10485760 ]]; then
  27.   echo "This installation requires at least 10GB of free disk space.";
  28.   exit 1
  29. fi
  30.  
  31. # Install tools for dig and systemctl
  32. echo "Preparing installation..."
  33. apt-get install git dnsutils systemd -y > /dev/null 2>&1
  34.  
  35. # Check for systemd
  36. systemctl --version >/dev/null 2>&1 || { echo "systemd is required. Are you using Ubuntu 16.04?"  >&2; exit 1; }
  37.  
  38. # CHARS is used for the loading animation further down.
  39. CHARS="/-\|"
  40. EXTERNALIP=`dig +short myip.opendns.com @resolver1.opendns.com`
  41. clear
  42.  
  43. echo "
  44.  
  45.    ___T_
  46.   | o o |
  47.   |__-__|
  48.   /| []|\\
  49. ()/|___|\()
  50.    |_|_|
  51.    /_|_\  ------- MASTERNODE INSTALLER v2 -------+
  52. |                                                |
  53. |You can choose between two installation options:|::
  54. |             default and advanced.              |::
  55. |                                                |::
  56. | The advanced installation will install and run |::
  57. |  the masternode under a non-root user. If you  |::
  58. |  don't know what that means, use the default   |::
  59. |              installation method.              |::
  60. |                                                |::
  61. | Otherwise, your masternode will not work, and  |::
  62. |the Bulwark Team CANNOT assist you in repairing |::
  63. |        it. You will have to start over.        |::
  64. |                                                |::
  65. |Don't use the advanced option unless you are an |::
  66. |            experienced Linux user.             |::
  67. |                                                |::
  68. +------------------------------------------------+::
  69.   ::::::::::::::::::::::::::::::::::::::::::::::::::
  70.  
  71. "
  72.  
  73. sleep 5
  74.  
  75. read -e -p "Use the Advanced Installation? [N/y] : " ADVANCED
  76.  
  77. if [[ ("$ADVANCED" == "y" || "$ADVANCED" == "Y") ]]; then
  78.  
  79. USER=bulwark
  80.  
  81. adduser $USER --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password > /dev/null
  82.  
  83. echo "" && echo 'Added user "bulwark"' && echo ""
  84. sleep 1
  85.  
  86. else
  87.  
  88. USER=root
  89.  
  90. fi
  91.  
  92. USERHOME=`eval echo "~$USER"`
  93.  
  94. read -e -p "Server IP Address: " -i $EXTERNALIP -e IP
  95. read -e -p "Masternode Private Key (e.g. 7edfjLCUzGczZi3JQw8GHp434R9kNY33eFyMGeKRymkB56G4324h # THE KEY YOU GENERATED EARLIER) : " KEY
  96. read -e -p "Install Fail2ban? [Y/n] : " FAIL2BAN
  97. read -e -p "Install UFW and configure ports? [Y/n] : " UFW
  98. read -e -p "Do you want to use our bootstrap file to speed the syncing process? [Y/n] : " BOOTSTRAP
  99.  
  100. clear
  101.  
  102. # Generate random passwords
  103. RPCUSER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
  104. RPCPASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
  105.  
  106. # update packages and upgrade Ubuntu
  107. echo "Installing dependencies..."
  108. apt-get -qq update
  109. apt-get -qq upgrade
  110. apt-get -qq autoremove
  111. apt-get -qq install wget htop unzip
  112. apt-get -qq install build-essential && apt-get -qq install libtool autotools-dev autoconf automake && apt-get -qq install libssl-dev && apt-get -qq install libboost-all-dev && apt-get -qq install software-properties-common && add-apt-repository -y ppa:bitcoin/bitcoin && apt update && apt-get -qq install libdb4.8-dev && apt-get -qq install libdb4.8++-dev && apt-get -qq install libminiupnpc-dev && apt-get -qq install libqt4-dev libprotobuf-dev protobuf-compiler && apt-get -qq install libqrencode-dev && apt-get -qq install git && apt-get -qq install pkg-config && apt-get -qq install libzmq3-dev
  113. apt-get -qq install aptitude
  114.  
  115. # Install Fail2Ban
  116. if [[ ("$FAIL2BAN" == "y" || "$FAIL2BAN" == "Y" || "$FAIL2BAN" == "") ]]; then
  117.   aptitude -y -q install fail2ban
  118.   service fail2ban restart
  119. fi
  120.  
  121. # Install UFW
  122. if [[ ("$UFW" == "y" || "$UFW" == "Y" || "$UFW" == "") ]]; then
  123.   apt-get -qq install ufw
  124.   ufw default deny incoming
  125.   ufw default allow outgoing
  126.   ufw allow ssh
  127.   ufw allow 52543/tcp
  128.   yes | ufw enable
  129. fi
  130.  
  131. # Install Bulwark daemon
  132. wget $TARBALLURL
  133. tar -xzvf $TARBALLNAME && mv bin bulwark-$BWKVERSION
  134. rm $TARBALLNAME
  135. cp ./bulwark-$BWKVERSION/bulwarkd /usr/local/bin
  136. cp ./bulwark-$BWKVERSION/bulwark-cli /usr/local/bin
  137. cp ./bulwark-$BWKVERSION/bulwark-tx /usr/local/bin
  138. rm -rf bulwark-$BWKVERSION
  139.  
  140. # Create .bulwark directory
  141. mkdir $USERHOME/.bulwark
  142.  
  143. # Install bootstrap file
  144. if [[ ("$BOOTSTRAP" == "y" || "$BOOTSTRAP" == "Y" || "$BOOTSTRAP" == "") ]]; then
  145.   echo "Installing bootstrap file..."
  146.   wget $BOOTSTRAPURL && unzip $BOOTSTRAPARCHIVE -d $USERHOME/.bulwark/ && rm $BOOTSTRAPARCHIVE
  147. fi
  148.  
  149. # Create bulwark.conf
  150. touch $USERHOME/.bulwark/bulwark.conf
  151. cat > $USERHOME/.bulwark/bulwark.conf << EOL
  152. rpcuser=${RPCUSER}
  153. rpcpassword=${RPCPASSWORD}
  154. rpcallowip=127.0.0.1
  155. listen=1
  156. server=1
  157. daemon=1
  158. logtimestamps=1
  159. maxconnections=256
  160. externalip=${IP}
  161. bind=${IP}:52543
  162. masternodeaddr=${IP}
  163. masternodeprivkey=${KEY}
  164. masternode=1
  165. EOL
  166. chmod 0600 $USERHOME/.bulwark/bulwark.conf
  167. chown -R $USER:$USER $USERHOME/.bulwark
  168.  
  169. sleep 1
  170.  
  171. cat > /etc/systemd/system/bulwarkd.service << EOL
  172. [Unit]
  173. Description=bulwarkd
  174. After=network.target
  175. [Service]
  176. Type=forking
  177. User=${USER}
  178. WorkingDirectory=${USERHOME}
  179. ExecStart=/usr/local/bin/bulwarkd -conf=${USERHOME}/.bulwark/bulwark.conf -datadir=${USERHOME}/.bulwark
  180. ExecStop=/usr/local/bin/bulwark-cli -conf=${USERHOME}/.bulwark/bulwark.conf -datadir=${USERHOME}/.bulwark stop
  181. Restart=on-abort
  182. [Install]
  183. WantedBy=multi-user.target
  184. EOL
  185. sudo systemctl enable bulwarkd
  186. sudo systemctl start bulwarkd
  187.  
  188. clear
  189.  
  190. cat << EOL
  191.  
  192. Now, you need to start your masternode. Please go to your desktop wallet and
  193. enter the following line into your debug console:
  194.  
  195. startmasternode alias false <mymnalias>
  196.  
  197. where <mymnalias> is the name of your masternode alias (without brackets)
  198.  
  199. EOL
  200.  
  201. read -p "Press any key to continue after you've done that. " -n1 -s
  202.  
  203. clear
  204.  
  205. echo "Your masternode is syncing. Please wait for this process to finish and then start your masternode."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement