chia.sh 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. #!/bin/bash
  2. set -e
  3. Gui=No #can be Yes No or Only
  4. Service=Yes
  5. Version=4.0
  6. MadMax=Yes
  7. GigaHorse=Yes
  8. BladeBit=Yes
  9. ChiaPos=Yes
  10. function print_centered {
  11. [[ $# == 0 ]] && return 1
  12. declare -i TERM_COLS="$(tput cols)"
  13. declare -i str_len="${#1}"
  14. [[ $str_len -ge $TERM_COLS ]] && {
  15. echo "$1";
  16. return 0;
  17. }
  18. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  19. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  20. filler=""
  21. for (( i = 0; i < filler_len; i++ )); do
  22. filler="${filler}${ch}"
  23. done
  24. printf "%s%s%s" "$filler" "$1" "$filler"
  25. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  26. printf "\n"
  27. return 0
  28. }
  29. function jumpto
  30. {
  31. label=$1
  32. cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$')
  33. eval "$cmd"
  34. exit
  35. }
  36. function simplify_config {
  37. error_flag=0
  38. Gui=${Gui^^}
  39. Service=${Service^^}
  40. MadMax=${MadMax^^}
  41. GigaHorse=${GigaHorse^^}
  42. BladeBit=${BladeBit^^}
  43. ChiaPos=${ChiaPos^^}
  44. if ! [ $MadMax = "YES" ] || [ $MadMax = "NO" ];then error_flag=1;fi
  45. if ! [ $GigaHorse = "YES" ] || [ $GigaHorse = "NO" ];then error_flag=1;fi
  46. if ! [ $BladeBit = "YES" ] || [ $BladeBit = "NO" ];then error_flag=1;fi
  47. if ! [ $ChiaPos = "YES" ] || [ $ChiaPos = "NO" ];then error_flag=1;fi
  48. if ! [ $Service = "YES" ] || [ $Service = "NO" ];then error_flag=1;fi
  49. }
  50. function intro_ {
  51. print_centered "$(tput setaf 10)"
  52. print_centered " ______ __ __ "
  53. print_centered "| | |--.|__|.---.-."
  54. print_centered "| ---| || || _ |"
  55. print_centered "|______|__|__||__||___._|"
  56. echo -n "$(tput sgr0)"
  57. print_centered "Toolkit for Chia v$Version"
  58. if [ $error_flag = 1 ]
  59. then
  60. echo -n "$(tput setaf 1 ;tput blink;tput bold)"
  61. print_centered "Config Error !!!"
  62. echo -n "$(tput sgr0)"
  63. exit 0
  64. fi
  65. case $Gui in
  66. YES)
  67. echo -n "$(tput setaf 11)"
  68. print_centered "Blockchain wallet + Gui"
  69. print_centered "Chia Plotting Tools"
  70. echo -n "$(tput sgr0)"
  71. ;;
  72. NO)
  73. echo -n "$(tput setaf 11)"
  74. print_centered "Chia Plotting Tools"
  75. echo -n "$(tput sgr0)"
  76. ;;
  77. ONLY)
  78. echo -n "$(tput setaf 11)"
  79. print_centered "Blockchain wallet Only"
  80. echo -n "$(tput sgr0)"
  81. ;;
  82. *)
  83. echo -n "$(tput setaf 1 ;tput blink;tput bold)"
  84. print_centered "Config Error !!!"
  85. echo -n "$(tput sgr0)"
  86. exit 0
  87. ;;
  88. esac
  89. if [ $Gui = "NO" ] || [ $Gui = "YES" ]
  90. then
  91. case $Service in
  92. YES)
  93. echo -n "$(tput setaf 11)"
  94. print_centered "Mining service Enabled"
  95. echo -n "$(tput sgr0)"
  96. ;;
  97. esac
  98. fi
  99. sleep 3
  100. }
  101. function update_ {
  102. echo -e "$(tput setaf 2)\nUpdate and install packages:$(tput sgr0)"
  103. sleep 1
  104. if grep "Drivers=NVIDIA" /home/wareck/Build_Cube/build_cube.sh >/dev/null
  105. then
  106. extend="libgomp1 ocl-icd-opencl-dev libgmp-dev libnuma-dev"
  107. else
  108. extend=""
  109. fi
  110. sudo apt-get install python3-venv python3-distutils python3-dev libsodium-dev $extend -y
  111. echo -e "\e[97mDone.\e[0m"
  112. }
  113. function chia_plotter {
  114. echo -e "$(tput setaf 2)\nBuild Chia-Plotter (MadMax4ever) :$(tput sgr0)"
  115. sleep 1
  116. cd /home/wareck
  117. if [ ! -d chia-plotter ]
  118. then
  119. git clone https://github.com/madMAx43v3r/chia-plotter.git
  120. else
  121. cd /home/wareck/chia-plotter
  122. git pull
  123. fi
  124. cd /home/wareck/chia-plotter
  125. git submodule init
  126. git submodule update
  127. ./make_devel.sh
  128. cd build
  129. cat <<'EOF'>> go.sh
  130. #!/bin/bash
  131. ./chia_plot -n 1 -r 4 -u 128 -t /media/nvme0/ -2 /media/nvme0/ -d /media/Partage/Plots/ -p a99e72c49c5ed39bf7>
  132. EOF
  133. chmod +x go.sh
  134. cat <<'EOF'>> nft.sh
  135. #!/bin/bash
  136. ./chia_plot -n 1 -r 4 -u 128 -t /media/nvme0/ -2 /media/nvme1/ -d /media/Partage/Plots-nft/ -c xch18c2jp56msc>
  137. EOF
  138. chmod +x nft.sh
  139. echo -e "\e[97mDone.\e[0m"
  140. }
  141. function bladebit {
  142. echo -e "$(tput setaf 2)\nBuild Bladebit v2 :$(tput sgr0)"
  143. sleep 1
  144. cd /home/wareck
  145. if [ ! -d bladebit ]
  146. then
  147. git clone https://github.com/Chia-Network/bladebit.git
  148. fi
  149. cd /home/wareck/bladebit/
  150. if [ ! -d build ];then mkdir build;fi
  151. cd build
  152. cmake ..
  153. make -j6
  154. echo -e "\e[97mDone.\e[0m"
  155. }
  156. function gigahorse {
  157. echo -e "$(tput setaf 2)\nMadMax4ever GigaHorse:$(tput sgr0)"
  158. sleep 1
  159. if [ -d /home/wareck/chia-gigahorse ]
  160. then
  161. cd /home/wareck/chia-gigahorse
  162. git pull
  163. else
  164. cd /home/wareck/
  165. git clone https://github.com/madMAx43v3r/chia-gigahorse.git
  166. fi
  167. echo "generate bash files..."
  168. sudo cp ~/chia-gigahorse/plot-sink/linux/x86_64/* /usr/local/bin/
  169. sudo cp ~/chia-gigahorse/cpu-plotter/linux/x86_64/* /usr/local/bin/
  170. cd ~
  171. if [ -f distrib_chia.sh ];then sudo rm distrib_chia.sh;fi
  172. if [ -f /usr/local/bin/distrib_chia.sh ];then sudo rm /usr/local/bin/distrib_chia.sh;fi
  173. cat <<'EOF'>> distrib_chia.sh
  174. #!/bin/bash
  175. echo "IP : $(hostname -I)"
  176. chia_plot_sink -p 1447 /Chia/Chia1/Plots-nft/ /Chia/Chia2/Plots-nft/ /Chia/Chia3/Plots-nft/ /Partage/Plots-nf>
  177. EOF
  178. chmod +x distrib_chia.sh
  179. sudo mv distrib_chia.sh /usr/local/bin/
  180. cat <<'EOF'>> ~/go.sh
  181. #!/bin/bash
  182. ./chia_plot -G -r 6 -z 1447 -C 8 -n -1 -t /nvme0/plotting/ -2 /nvme1/plotting/ -d @192.168.1.100 \
  183. -c xch10yjksfwm8s66z32qy35x950608hk8l67vmsur4rwpaanpkd6ks3qhfw5nk \
  184. -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  185. EOF
  186. chmod +x ~/go.sh
  187. cp ~/go.sh ~/chia-gigahorse/cpu-plotter/linux/x86_64/
  188. rm ~/go.sh
  189. echo -e "\e[97mDone.\e[0m"
  190. }
  191. function chiapos {
  192. echo -e "$(tput setaf 2)\nBuild Chia-Pos:$(tput sgr0)"
  193. sleep 1
  194. cd /home/wareck/
  195. if [ ! -d /home/wareck/chia-pos ]
  196. then
  197. git clone https://github.com/Chia-Network/chiapos.git chia-pos
  198. cd /home/wareck/chia-pos
  199. else
  200. cd /home/wareck/chia-pos
  201. git pull
  202. fi
  203. if [ ! -d build ]; then mkdir build;fi
  204. cd build
  205. cmake -DBUILD_PROOF_OF_SPACE_STATICALLY=ON ../
  206. cmake --build . -- -j 6
  207. echo -e "\e[97mDone.\e[0m"
  208. }
  209. function miner {
  210. echo -e "$(tput setaf 2)\nChia-Miner (hpool):$(tput sgr0)"
  211. sleep 1
  212. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/chia-miner.tar.xz -O /home/wareck/Build_Cube/pack/chia-miner.tar.xz
  213. cp /home/wareck/Build_Cube/pack/chia-miner.tar.xz /home/wareck/miners
  214. cd /home/wareck/miners
  215. tar xvfJ chia-miner.tar.xz
  216. rm chia-miner.tar.xz
  217. echo -e "\e[97mDone.\e[0m"
  218. }
  219. function chia_blockchain {
  220. echo -e "$(tput setaf 2)\nBuild Chia-blockchain & Gui :$(tput sgr0)"
  221. sleep 1
  222. cd /home/wareck
  223. if [ ! -d /home/wareck/chia-blockchain ]
  224. then
  225. git clone https://github.com/Chia-Network/chia-blockchain.git -b latest --recurse-submodules
  226. cd chia-blockchain
  227. else
  228. cd chia-blockchain
  229. git pull
  230. fi
  231. sh install.sh
  232. source ./activate
  233. sh install-gui.sh
  234. echo -e "\e[97mDone.\e[0m"
  235. }
  236. function service_ {
  237. echo -e "$(tput setaf 2)\nInstall chia-miner service (hpool) :$(tput sgr0)"
  238. sleep 1
  239. echo "Generation du fichier /etc/init.d/chia-miner"
  240. cat <<'EOF'>> chia-miner.sh
  241. #!/bin/sh -e
  242. ### BEGIN INIT INFO
  243. # Provides: chiaminer
  244. # Required-Start: networking
  245. # Default-Start: 3 4 5
  246. # Default-Stop: 0 6
  247. ### END INIT INFO
  248. case "$1" in
  249. start|restart)
  250. cd /home/wareck/miners/chia-miner/
  251. sudo killall -9 hpool-miner-chia > /dev/null 2>&1
  252. sleep 1
  253. su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config.yaml"
  254. ;;
  255. stop)
  256. sudo killall -9 hpool-miner-chia | true
  257. ;;
  258. *)
  259. echo "Usage: /etc/init.d/chia-miner {start|stop|restart}"
  260. exit 1
  261. ;;
  262. esac
  263. exit 0
  264. EOF
  265. chmod +x chia-miner.sh
  266. sudo cp chia-miner.sh /etc/init.d/chia-miner
  267. sudo update-rc.d chia-miner defaults
  268. sudo rm chia-miner.sh
  269. echo -e "\e[97mDone.\e[0m"
  270. }
  271. simplify_config
  272. intro_
  273. update_
  274. case $Gui in
  275. YES|ONLY)
  276. chia_blockchain
  277. ;;
  278. NO)
  279. if [ $MadMax = "YES" ];then chia_plotter;fi
  280. if [ $BladeBit = "YES" ];then bladebit;fi
  281. if [ $GigaHorse = "YES" ];then gigahorse;fi
  282. if [ $ChiaPos = "YES" ];then chiapos;fi
  283. if [ $Service = "YES" ];then service_;fi
  284. ;;
  285. *)
  286. ;;
  287. esac
  288. echo -e "\n\e[97mEnd of process...\e[0m"