build_miner_mod.sh 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #!/bin/bash
  2. #####################################################################
  3. # Minera builder script to build and update miner software binaries
  4. #
  5. # For usage just run the build_miner.sh without any argument
  6. #
  7. # Thanks to @brettvitaz https://github.com/brettvitaz
  8. #
  9. # modded by wareck@gmail.com
  10. #
  11. #####################################################################
  12. set -u
  13. set -e
  14. VERSION=3.4.0306
  15. LINK_ONLY=0
  16. BUILD_OK=0
  17. DYNLINK=0
  18. MINERA_PATH="/var/www/minera"
  19. BINARY_PATH="$MINERA_PATH/minera-bin"
  20. SOURCE_PATH="$BINARY_PATH/src"
  21. CPUMINER_REPO="https://github.com/siklon/cpuminer-gc3355"
  22. CPUMINER_PATH="$SOURCE_PATH/cpuminer-gc3355"
  23. CPUMINER_CONFIG="CFLAGS=-O3"
  24. CPUMINER_BINARY="minerd"
  25. CPUMINER_MINERA_BINARY="minerd"
  26. BFGMINER_REPO="https://github.com/luke-jr/bfgminer.git"
  27. BFGMINER_PATH="$SOURCE_PATH/bfgminer"
  28. BFGMINER_CONFIG="--enable-scrypt --enable-keccak --enable-bfsb --enable-broad-udevrules --without-system-libbase58"
  29. BFGMINER_BINARY="bfgminer"
  30. BFGMINER_MINERA_BINARY="bfgminer"
  31. CGMINER_DMAXL_REPO="https://github.com/wareck/cgminer-lketc.git"
  32. CGMINER_DMAXL_PATH="$SOURCE_PATH/cgminer-lketc"
  33. CGMINER_DMAXL_CONFIG="--enable-scrypt --enable-gridseed --enable-zeus --enable-lketc"
  34. CGMINER_DMAXL_BINARY="cgminer"
  35. CGMINER_DMAXL_MINERA_BINARY="cgminer-dmaxl-zeus"
  36. CGMINER_REPO="https://github.com/ckolivas/cgminer.git"
  37. CGMINER_PATH="$SOURCE_PATH/cgminer"
  38. CGMINER_CONFIG="--enable-avalon --enable-bflsc --enable-bitforce --enable-bitfury --enable-blockerupter --enable-cointerra --enable-drillbit --enable-hashfast --enable-hashratio --enable-icarus --enable-klondike --enable-modminer"
  39. CGMINER_BINARY="cgminer"
  40. CGMINER_MINERA_BINARY="cgminer"
  41. BITMINER_REPO="https://github.com/wareck/cgminer-hexminer.git"
  42. BITMINER_PATH="$SOURCE_PATH/cgminer-hex"
  43. BITMINER_CONFIG="--enable-hexminera --enable-hexminerb --enable-hexmineru --enable-hexminerc --enable-hexminer8 --enable-hexminerm --enable-hexminerr --enable-hexminerbe200 --enable-hexminer3"
  44. BITMINER_BINARY="cgminer"
  45. BITMINER_MINERA_BINARY="cgminer-hex"
  46. CGMINER_GK_REPO="https://wareck@bitbucket.org/wareck/cgminer-gekko.git"
  47. CGMINER_GK_PATH="$SOURCE_PATH/cgminer-gekko"
  48. CGMINER_GK_CONFIG="--enable-gekko --enable-bflsc --enable-icarus"
  49. CGMINER_GK_BINARY="cgminer"
  50. CGMINER_GK_MINERA_BINARY="cgminer-gekko"
  51. BFGMINER_MOON_REPO="--branch futurebit_driver https://github.com/jstefanop/bfgminer.git"
  52. BFGMINER_MOON_PATH="$SOURCE_PATH/bfgminer-moon"
  53. BFGMINER_MOON_CONFIG="--enable-scrypt --enable-scrypt --enable-futurebit --disable-other-drivers"
  54. BFGMINER_MOON_BINARY="bfgminer"
  55. BFGMINER_MOON_MINERA_BINARY="bfgminer-moon"
  56. function buildMiner {
  57. if [[ $LINK_ONLY -eq 0 ]]; then
  58. if [[ -d "$BUILD_PATH/.git" ]]; then
  59. cd $BUILD_PATH
  60. echo "Pulling repo $BUILD_REPO"
  61. git fetch --all
  62. git reset --hard
  63. else
  64. echo "Cloning repo $BUILD_REPO into $BUILD_PATH"
  65. git clone $BUILD_REPO $BUILD_PATH
  66. cd $BUILD_PATH
  67. fi
  68. ./autogen.sh
  69. echo "Running ./configure $BUILD_CONFIG"
  70. ./configure ${BUILD_CONFIG}
  71. make
  72. sudo make install
  73. sudo ldconfig
  74. fi
  75. if [[ -f $BINARY_PATH/$MINERA_BINARY ]]; then
  76. sleep 1
  77. else
  78. echo "build temporary file..."
  79. touch $BINARY_PATH/$MINERA_BINARY
  80. fi
  81. if [[ -e "$BUILD_PATH/$BUILD_BINARY" ]]; then
  82. echo "Removing old binary $BINARY_PATH/$MINERA_BINARY"
  83. rm $BINARY_PATH/$MINERA_BINARY
  84. echo "Copying new binary $BUILD_PATH/$BUILD_BINARY -> $BINARY_PATH/$MINERA_BINARY"
  85. cp $BUILD_PATH/$BUILD_BINARY $BINARY_PATH/$MINERA_BINARY
  86. else
  87. echo "Failed to copy miner binary. File $BUILD_PATH/$BUILD_BINARY does not exist."
  88. fi
  89. if [[ $DYNLINK -eq 1 ]]; then
  90. if [[ -e "/var/www/minera/minera-bin/custom/$MINERA_BINARY" ]]; then
  91. rm /var/www/minera/minera-bin/custom/$MINERA_BINARY
  92. fi
  93. echo "Creating symlink to custom miner"
  94. ln -s $BINARY_PATH/$MINERA_BINARY /var/www/minera/minera-bin/custom/$MINERA_BINARY
  95. fi
  96. }
  97. ARGS="${@/%all/cpuminer bfgminer cgminer-dmaxl cgminer cgminer-hex cgminer-gekko bfgminer-moon}"
  98. if [[ -d "$SOURCE_PATH" ]]; then
  99. for OPT in $ARGS; do
  100. echo "$OPT"
  101. if [[ $OPT = "-l" ]]; then
  102. LINK_ONLY=1
  103. elif [[ $OPT = "all" ]]; then
  104. ARGS="cpuminer bfgminer cgminer-dmaxl cgminer cgminer-hex cgminer-gekko bfgminer-moon"
  105. elif [[ $OPT = "cpuminer" ]]; then
  106. BUILD_REPO=$CPUMINER_REPO
  107. BUILD_PATH=$CPUMINER_PATH
  108. BUILD_CONFIG=$CPUMINER_CONFIG
  109. BUILD_BINARY=$CPUMINER_BINARY
  110. MINERA_BINARY=$CPUMINER_MINERA_BINARY
  111. BUILD_OK=1
  112. elif [[ $OPT = "bfgminer" ]]; then
  113. BUILD_REPO=$BFGMINER_REPO
  114. BUILD_PATH=$BFGMINER_PATH
  115. BUILD_CONFIG=$BFGMINER_CONFIG
  116. BUILD_BINARY=$BFGMINER_BINARY
  117. MINERA_BINARY=$BFGMINER_MINERA_BINARY
  118. BUILD_OK=1
  119. elif [[ $OPT = "cgminer-dmaxl" ]]; then
  120. BUILD_REPO=$CGMINER_DMAXL_REPO
  121. BUILD_PATH=$CGMINER_DMAXL_PATH
  122. BUILD_CONFIG=$CGMINER_DMAXL_CONFIG
  123. BUILD_BINARY=$CGMINER_DMAXL_BINARY
  124. MINERA_BINARY=$CGMINER_DMAXL_MINERA_BINARY
  125. BUILD_OK=1
  126. elif [[ $OPT = "cgminer" ]]; then
  127. BUILD_REPO=$CGMINER_REPO
  128. BUILD_PATH=$CGMINER_PATH
  129. BUILD_CONFIG=$CGMINER_CONFIG
  130. BUILD_BINARY=$CGMINER_BINARY
  131. MINERA_BINARY=$CGMINER_MINERA_BINARY
  132. BUILD_OK=1
  133. elif [[ $OPT = "cgminer-hex" ]]; then
  134. BUILD_REPO=$BITMINER_REPO
  135. BUILD_PATH=$BITMINER_PATH
  136. BUILD_CONFIG=$BITMINER_CONFIG
  137. BUILD_BINARY=$BITMINER_BINARY
  138. MINERA_BINARY=$BITMINER_MINERA_BINARY
  139. BUILD_OK=1
  140. DYNLINK=1
  141. elif [[ $OPT = "cgminer-gekko" ]]; then
  142. BUILD_REPO=$CGMINER_GK_REPO
  143. BUILD_PATH=$CGMINER_GK_PATH
  144. BUILD_CONFIG=$CGMINER_GK_CONFIG
  145. BUILD_BINARY=$CGMINER_GK_BINARY
  146. MINERA_BINARY=$CGMINER_GK_MINERA_BINARY
  147. BUILD_OK=1
  148. DYNLINK=1
  149. elif [[ $OPT = "bfgminer-moon" ]]; then
  150. BUILD_REPO=$BFGMINER_MOON_REPO
  151. BUILD_PATH=$BFGMINER_MOON_PATH
  152. BUILD_CONFIG=$BFGMINER_MOON_CONFIG
  153. BUILD_BINARY=$BFGMINER_MOON_BINARY
  154. MINERA_BINARY=$BFGMINER_MOON_MINERA_BINARY
  155. BUILD_OK=1
  156. DYNLINK=1
  157. else
  158. echo "Option not recognized = $OPT"
  159. BUILD_OK=0
  160. fi
  161. if [[ $BUILD_OK -eq 1 ]]; then
  162. buildMiner
  163. fi
  164. done
  165. if [[ $BUILD_OK -eq 0 ]]; then
  166. echo " "
  167. echo -e "\e[1m\e[33mBinary mining autobuilder \e[31mv$VERSION"
  168. echo -e "\e[0m\e[39mUsage: build_miner.sh [OPTION] [MINER NAME(S)]..."
  169. echo ""
  170. echo "Arguments:"
  171. echo " -l Link binaries only (do not build)"
  172. echo ""
  173. echo "Miner Names:"
  174. echo " cgminer cgminer official"
  175. echo " cpuminer cpuminer GC3355 fork"
  176. echo " bfgminer bfgminer official"
  177. echo " cgminer-dmaxl cgminer dmaxl fork (GridSeed and Zeus support)"
  178. echo " cgminer-hex cgminer special HexMiner"
  179. echo " cgminer-gekko cgminer with gekko support"
  180. echo " bfgminer-moon bfgminer Futurebit Moonlander"
  181. echo " all build all the above"
  182. echo ""
  183. fi
  184. else
  185. echo "Minera source folder does not exist. Please install Minera prior to building the miners."
  186. fi