deploy.sh 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. #!/bin/bash
  2. export VERSION=1.2
  3. export REV=21-04-2017
  4. set -e
  5. set +x
  6. export SRC_DIR=$(cd $(dirname $0) && pwd)
  7. ESC=$(echo -en \\0033)
  8. BOLD="$ESC[1m"
  9. OFF="$ESC[0m"
  10. bold() {
  11. echo "$BOLD$1$OFF"
  12. }
  13. fail() {
  14. bold "$@"
  15. exit 1
  16. }
  17. full() { # full automation
  18. clear
  19. echo -e "\e[031m${BOLD}Minera auto_install v:$VERSION rev:$REV $OFF"
  20. echo -e "\e[031m${BOLD}Full installation$OFF"
  21. sudo apt-get update
  22. sudo apt-get install git postfix -y
  23. sleep 3
  24. init
  25. deploy
  26. sudo rm -r -f /var/www/minera/minera-bin/src/libblkmaker
  27. miners
  28. }
  29. init() { # Update and install prerequise
  30. clear
  31. echo -e "\e[031m${BOLD}Minera auto_install v:$VERSION rev:$REV $OFF"
  32. echo -e "\e[033m${BOLD}Raspberry Update:$OFF"
  33. sudo apt-get update
  34. sudo apt-get upgrade -y
  35. echo -e "\e[033m${BOLD}Install prerequises:$OFF"
  36. sudo apt-get install lighttpd php5-cgi dosfstools -y
  37. #sudo lighty-enable-mod fastcgi
  38. #sudo lighty-enable-mod fastcgi-php
  39. sleep 1
  40. if [ -f "/usr/sbin/rpi-clone" ];
  41. then echo -e "\e[039m${BOLD}Install rpi-clone: Already installed$OFF"
  42. else
  43. echo -e "\e[033m${BOLD}Install: rpi-clone$OFF"
  44. cd ..
  45. git clone https://github.com/billw2/rpi-clone.git
  46. cd rpi-clone
  47. sudo cp rpi-clone /usr/sbin
  48. fi
  49. echo -e "\e[033m${BOLD}Install: fastcgi$OFF"
  50. sudo apt-get install -y redis-server git screen php5-cli php5-curl
  51. sudo apt-get autoremove -y
  52. sudo /etc/init.d/lighttpd restart
  53. cd "$SRC_DIR"
  54. }
  55. deploy() { # Install Minera with my patched files
  56. if [ ! -d "/var/www/minera" ];
  57. then cd /var/www/
  58. sudo git clone https://github.com/michelem09/minera
  59. cd minera
  60. sudo git checkout 8890458b3dbb36cdc4bfb29c350759aec2588baf
  61. fi
  62. cd /var/www/minera
  63. echo -e "\e[033m${BOLD}Install: Patch:$OFF"
  64. sudo cp $SRC_DIR/files/patch_no_ads.diff .
  65. sudo patch -p1 <patch_no_ads.diff
  66. sudo ./install_minera.sh
  67. }
  68. miners() { # Install all modded miners
  69. cd /var/www/minera
  70. echo -e "\e[033m${BOLD}Building miners software:$OFF"
  71. sudo apt-get install build-essential autoconf automake libtool pkg-config libcurl4-openssl-dev libncursesw5-dev libgcrypt20-dev -y
  72. sudo apt-get install libjansson-dev uthash-dev libncurses5-dev libudev-dev libusb-1.0-0-dev libevent-dev libmicrohttpd-dev -y
  73. sudo cp $SRC_DIR/files/build_miner_mod.sh .
  74. cd /var/www/minera/minera-bin/src/
  75. if [ -d "/var/www/minera/minera-bin/src/libbase58" ];
  76. then cd /var/www/minera/minera-bin/src/libbase58
  77. LOCAL=$(git rev-parse @)
  78. REMOTE=$(git rev-parse @{u})
  79. if [ $LOCAL = $REMOTE ]; then
  80. sudo make install
  81. echo -e "\e[039m${BOLD}Install libbase58 library: Up-to-date$OFF"
  82. elif [ $LOCAL = $BASE ]; then
  83. echo -e "\e[033m${BOLD}Install libbase58 drivers:$OFF"
  84. echo "Need to pull"
  85. sudo git pull
  86. sudo ./autogen.sh
  87. sudo ./configure
  88. sudo make
  89. sudo make install
  90. sudo ldconfig
  91. fi
  92. else echo -e "\e[033m${BOLD}Install libbase58 library:$OFF"
  93. cd /var/www/minera/minera-bin/src/
  94. git clone https://github.com/luke-jr/libbase58.git
  95. cd libbase58
  96. sudo ./autogen.sh
  97. sudo ./configure
  98. sudo make
  99. sudo make install
  100. sudo ldconfig
  101. fi
  102. if [ -d "/var/www/minera/minera-bin/src/hidapi" ];
  103. then cd /var/www/minera/minera-bin/src/hidapi
  104. LOCAL=$(git rev-parse @)
  105. REMOTE=$(git rev-parse @{u})
  106. if [ $LOCAL = $REMOTE ]; then
  107. sudo make install
  108. echo -e "\e[039m${BOLD}Install Hidapi drivers: Up-to-date$OFF"
  109. elif [ $LOCAL = $BASE ]; then
  110. echo -e "\e[033m${BOLD}Install Hidapi drivers:$OFF"
  111. echo "Need to pull"
  112. sudo git pull
  113. sudo ./bootstrap
  114. sudo ./configure
  115. sudo make
  116. sudo make install
  117. fi
  118. else echo -e "\e[033m${BOLD}Install Hidapi drivers:$OFF"
  119. cd /var/www/minera/minera-bin/src/
  120. git clone https://github.com/signal11/hidapi.git
  121. cd /var/www/minera/minera-bin/src/hidapi
  122. sudo apt-get install libudev-dev libusb-1.0-0-dev libfox-1.6-dev -y
  123. sudo ./bootstrap
  124. sudo ./configure
  125. sudo make
  126. sudo make install
  127. fi
  128. if [ -d "/var/www/minera/minera-bin/src/libblkmaker" ];
  129. then cd /var/www/minera/minera-bin/src/libblkmaker
  130. LOCAL=$(git rev-parse @)
  131. REMOTE=$(git rev-parse @{u})
  132. if [ $LOCAL = $REMOTE ]; then
  133. sudo make install
  134. echo -e "\e[039m${BOLD}Install libblmaker libs: Up-to-date$OFF"
  135. elif [ $LOCAL = $BASE ]; then
  136. echo -e "\e[033m${BOLD}Install libblmaker libs:$OFF"
  137. echo "Need to pull"
  138. sudo git pull
  139. sudo ./autogen.sh
  140. sudo ./configure
  141. sudo make
  142. sudo make install
  143. fi
  144. else echo -e "\e[033m${BOLD}Install libblmaker libs:$OFF"
  145. cd /var/www/minera/minera-bin/src
  146. git clone https://github.com/bitcoin/libblkmaker.git
  147. cd /var/www/minera/minera-bin/src/libblkmaker
  148. sudo ./autogen.sh
  149. sudo ./configure
  150. sudo make
  151. sudo make install
  152. fi
  153. cd /var/www/minera
  154. sudo ./build_miner_mod.sh all
  155. }
  156. patch_only() { # Patch only for original minera v7
  157. echo -e "\e[033m${BOLD}Install: Patch:$OFF"
  158. cd /var/www/minera
  159. sudo cp $SRC_DIR/files/patch_no_ads.diff .
  160. sudo patch -p1 <patch_no_ads.diff
  161. echo -e "\e[033m${BOLD}Patch : installed $OFF"
  162. }
  163. cd "$SRC_DIR"
  164. case "$1" in
  165. full) full;;
  166. init) init;;
  167. deploy) deploy;;
  168. miners) miners;;
  169. patch_only) patch_only;;
  170. *)
  171. echo -e "\e[031m${BOLD}Minera auto_install v:$VERSION rev:$REV $OFF"
  172. echo -e "${BOLD}Usage: $0 ( full | init | deploy | patch_only | miners )$OFF"
  173. echo >&2
  174. echo >&2 "Build actions:"
  175. grep "() { #" $0 | grep -v grep | sed -e "s:^: :" -e "s:() { #: @:" | while read i; do
  176. echo " " $(eval "echo $i") | tr @ \\t
  177. done
  178. exit 1
  179. ;;
  180. esac