chia.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. #!/bin/bash
  2. set -e
  3. Gui=No #can be Yes No or Only
  4. Version=5.0.0
  5. MadMax=Yes
  6. GigaHorse=Yes
  7. BladeBit=Yes
  8. ChiaPos=Yes
  9. ChiaService=Yes
  10. Miner=Yes
  11. ChiaProxy=Yes
  12. function print_centered {
  13. [[ $# == 0 ]] && return 1
  14. declare -i TERM_COLS="$(tput cols)"
  15. declare -i str_len="${#1}"
  16. [[ $str_len -ge $TERM_COLS ]] && {
  17. echo "$1";
  18. return 0;
  19. }
  20. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  21. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  22. filler=""
  23. for (( i = 0; i < filler_len; i++ )); do
  24. filler="${filler}${ch}"
  25. done
  26. printf "%s%s%s" "$filler" "$1" "$filler"
  27. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  28. printf "\n"
  29. return 0
  30. }
  31. function jumpto
  32. {
  33. label=$1
  34. cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$')
  35. eval "$cmd"
  36. exit
  37. }
  38. function simplify_config {
  39. error_flag=0
  40. Gui=${Gui^^}
  41. ChiaService=${ChiaService^^}
  42. MadMax=${MadMax^^}
  43. GigaHorse=${GigaHorse^^}
  44. BladeBit=${BladeBit^^}
  45. ChiaPos=${ChiaPos^^}
  46. Miner=${Miner^^}
  47. ChiaProxy=${ChiaProxy^^}
  48. if [ $MadMax = "YES" ] || [ $MadMax = "NO" ];then error_flag=0;else error_flag=1;fi
  49. if [ $GigaHorse = "YES" ] || [ $GigaHorse = "NO" ];then error_flag=0;else error_flag=1;fi
  50. if [ $BladeBit = "YES" ] || [ $BladeBit = "NO" ];then error_flag=0;else error_flag=1;fi
  51. if [ $ChiaPos = "YES" ] || [ $ChiaPos = "NO" ];then error_flag=0;else error_flag=1;fi
  52. if [ $ChiaService = "YES" ] || [ $ChiaService = "NO" ];then error_flag=0;else error_flag=1;fi
  53. if [ $Miner = "YES" ] || [ $Miner = "NO" ];then error_flag=0;else error_flag=1;fi
  54. if [ $ChiaProxy = "YES" ] || [ $ChiaProxy = "NO" ];then error_flag=0;else error_flag=1;fi
  55. }
  56. function intro_ {
  57. print_centered "$(tput setaf 10)"
  58. print_centered " ______ __ __ "
  59. print_centered "| | |--.|__|.---.-."
  60. print_centered "| ---| || || _ |"
  61. print_centered "|______|__|__||__||___._|"
  62. echo -n "$(tput sgr0)"
  63. print_centered "Toolkit for Chia v$Version"
  64. if [ $error_flag = 1 ]
  65. then
  66. echo -n "$(tput setaf 1 ;tput blink;tput bold)"
  67. print_centered "Config Error !!!"
  68. echo -n "$(tput sgr0)"
  69. exit 0
  70. fi
  71. case $Gui in
  72. YES)
  73. echo -n "$(tput setaf 11)"
  74. print_centered "Blockchain wallet + Gui"
  75. print_centered "Chia Plotting Tools"
  76. echo -n "$(tput sgr0)"
  77. ;;
  78. NO)
  79. echo -n "$(tput setaf 11)"
  80. print_centered "Chia Plotting Tools"
  81. echo -n "$(tput sgr0)"
  82. ;;
  83. ONLY)
  84. echo -n "$(tput setaf 11)"
  85. print_centered "Blockchain wallet Only"
  86. echo -n "$(tput sgr0)"
  87. ;;
  88. *)
  89. echo -n "$(tput setaf 1 ;tput blink;tput bold)"
  90. print_centered "Config Error !!!"
  91. echo -n "$(tput sgr0)"
  92. exit 0
  93. ;;
  94. esac
  95. if [ $Gui = "NO" ] || [ $Gui = "YES" ]
  96. then
  97. case $ChiaService in
  98. YES)
  99. echo -n "$(tput setaf 11)"
  100. print_centered "Mining service Enabled"
  101. echo -n "$(tput sgr0)"
  102. ;;
  103. esac
  104. case $ChiaProxy in
  105. YES)
  106. echo -n "$(tput setaf 11)"
  107. print_centered "Hpool x-Proxy Enabled"
  108. echo -n "$(tput sgr0)"
  109. ;;
  110. esac
  111. fi
  112. sleep 3
  113. if ! [ -d /home/wareck/chia ];then mkdir /home/wareck/chia;fi
  114. }
  115. function update_ {
  116. echo -e "$(tput setaf 10)\nUpdate and install packages:$(tput sgr0)"
  117. extend="libgomp1 ocl-icd-opencl-dev libgmp-dev libnuma-dev"
  118. sudo apt-get install python3-venv python3-distutils python3-dev libsodium-dev $extend -y
  119. echo -e "\e[97mDone.\e[0m"
  120. }
  121. function chia_plotter {
  122. echo -e "$(tput setaf 10)\nBuild Chia-Plotter (MadMax4ever) :$(tput sgr0)"
  123. sleep 1
  124. cd /home/wareck/chia/
  125. if [ ! -d chia-plotter ]
  126. then
  127. git clone https://github.com/madMAx43v3r/chia-plotter.git
  128. else
  129. cd /home/wareck/chia/chia-plotter
  130. git pull
  131. fi
  132. cd /home/wareck/chia/chia-plotter
  133. git submodule init
  134. git submodule update
  135. ./make_devel.sh
  136. cd build
  137. cat <<'EOF'>> go.sh
  138. #!/bin/bash
  139. POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
  140. FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  141. OUT=/media/Partage/Plots/
  142. ./chia_plot -p $POOL -f $FARM -n 1 -r 6 -u 128 -t /nvme0/plotting/ -2 /nvme0/plotting/ -d $OUT
  143. EOF
  144. chmod +x go.sh
  145. cat <<'EOF'>> nft.sh
  146. #!/bin/bash
  147. POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
  148. FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  149. OUT=/media/Partage/Plots-nft/
  150. ./chia_plot -p $POOL -f $FARM -n 1 -r 4 -u 128 -t /nvme0/plotting/ -2 /nvme1/plotting/ -d $OUT
  151. EOF
  152. chmod +x nft.sh
  153. echo -e "\e[97mDone.\e[0m"
  154. }
  155. function bladebit {
  156. echo -e "$(tput setaf 10)\nBuild Bladebit v2 :$(tput sgr0)"
  157. sleep 1
  158. cd /home/wareck/chia
  159. if [ ! -d bladebit ]
  160. then
  161. git clone https://github.com/Chia-Network/bladebit.git
  162. fi
  163. cd /home/wareck/chia/bladebit/
  164. if [ ! -d build ];then mkdir build;fi
  165. cd build
  166. cmake ..
  167. make -j6
  168. cat <<'EOF'>> cuda.sh
  169. #!/bin/bash
  170. ./bladebit_cuda \
  171. -c xch10yjksfwm8s66z32qy35x950608hk8l67vmsur4rwpaanpkd6ks3qhfw5nk \
  172. -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373 \
  173. diskplot -t1 /nvme0/plotting/ -t2 /nvme1/plotting/ /farm/farm0/Plots/
  174. EOF
  175. cat <<'EOF'>> flex.sh
  176. #!/bin/bash
  177. CRT=xch10yjksfwm8s66z32qy35x950608hk8l67vmsur4rwpaanpkd6ks3qhfw5nk
  178. FRM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  179. OUT=/media/Partage/Plots-nft/
  180. ./bladebit -f $FRM -c $CRT diskplot --cache 100G -t1 /nvme1/plotting/ -t2 /nvme1/plotting/ $OUT
  181. EOF
  182. cat <<'EOF'>> cuda_h9.sh
  183. #!/bin/bash
  184. #!/bin/bash
  185. POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
  186. FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  187. OUT=/farm/farm4/Plots
  188. ./bladebit_cuda -p $POOL -f $FARM -z 7 cudaplot -d 0 --disk-16 -t1 /nvme0/plotting $OUT
  189. EOF
  190. chmod +x cuda.sh
  191. chmod +x flex.sh
  192. chmod +x cuda_h9.sh
  193. echo -e "\e[97mDone.\e[0m"
  194. }
  195. function gigahorse {
  196. echo -e "$(tput setaf 10)\nMadMax4ever GigaHorse:$(tput sgr0)"
  197. sleep 1
  198. if [ -d /home/wareck/chia/chia-gigahorse ]
  199. then
  200. cd /home/wareck/chia/chia-gigahorse
  201. git pull
  202. else
  203. cd /home/wareck/chia/
  204. git clone https://github.com/madMAx43v3r/chia-gigahorse.git
  205. fi
  206. echo "generate bash files..."
  207. sudo cp ~/chia/chia-gigahorse/plot-sink/linux/x86_64/* /usr/local/bin/
  208. sudo cp ~/chia/chia-gigahorse/cpu-plotter/linux/x86_64/* /usr/local/bin/
  209. cd ~
  210. if [ -f distrib_chia.sh ];then sudo rm distrib_chia.sh;fi
  211. if [ -f /usr/local/bin/distrib_chia.sh ];then sudo rm /usr/local/bin/distrib_chia.sh;fi
  212. cat <<'EOF'>> distrib_chia.sh
  213. #!/bin/bash
  214. echo "IP : $(hostname -I)"
  215. chia_plot_sink -p 1447 /farm/farm0/Plots-nft/ /farm/farm1/Plots-nft/ /farm/farm2/Plots-nft/ /farm/farm3/Plots-nft/ /farm/farm4/Plots-nft/ /Partage/Plots-nft/
  216. EOF
  217. chmod +x distrib_chia.sh
  218. sudo mv distrib_chia.sh /usr/local/bin/
  219. cat <<'EOF'>> ~/go.sh
  220. #!/bin/bash
  221. CRT=xch10yjksfwm8s66z32qy35x950608hk8l67vmsur4rwpaanpkd6ks3qhfw5nk
  222. FRM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  223. OUT=@192.168.1.100
  224. ./chia_plot -c $CRT -f $FRM -G -r 6 -z 1447 -C 8 -n -1 -t /nvme0/plotting/ -2 /nvme1/plotting/ -d $OUT
  225. EOF
  226. chmod +x ~/go.sh
  227. cp ~/go.sh ~/chia/chia-gigahorse/cpu-plotter/linux/x86_64/
  228. rm ~/go.sh
  229. echo -e "\e[97mDone.\e[0m"
  230. }
  231. function chiapos {
  232. echo -e "$(tput setaf 10)\nBuild Chia-Pos:$(tput sgr0)"
  233. sleep 1
  234. cd /home/wareck/chia
  235. if [ ! -d /home/wareck/chia/chia-pos ]
  236. then
  237. git clone https://github.com/Chia-Network/chiapos.git chia-pos
  238. cd /home/wareck/chia/chia-pos
  239. else
  240. cd /home/wareck/chia/chia-pos
  241. git pull
  242. fi
  243. if [ ! -d build ]; then mkdir build;fi
  244. cd build
  245. cmake ..
  246. cmake --build . -- -j 6
  247. echo -e "\e[97mDone.\e[0m"
  248. }
  249. function miner_ {
  250. echo -e "$(tput setaf 10)\nChia-Miner (hpool):$(tput sgr0)"
  251. sleep 1
  252. 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
  253. cp /home/wareck/Build_Cube/pack/chia-miner.tar.xz /home/wareck/miners
  254. cd /home/wareck/miners
  255. tar xvfJ chia-miner.tar.xz
  256. rm chia-miner.tar.xz
  257. echo -e "\e[97mDone.\e[0m"
  258. }
  259. function chia_blockchain {
  260. echo -e "$(tput setaf 10)\nBuild Chia-blockchain & Gui :$(tput sgr0)"
  261. sleep 1
  262. cd /home/wareck/chia
  263. if [ ! -d /home/wareck/chia/chia-blockchain ]
  264. then
  265. git clone https://github.com/Chia-Network/chia-blockchain.git -b latest --recurse-submodules
  266. cd chia-blockchain
  267. else
  268. cd chia-blockchain
  269. git pull
  270. fi
  271. sh install.sh
  272. source ./activate
  273. sh install-gui.sh
  274. echo -e "\e[97mDone.\e[0m"
  275. }
  276. function chia_proxy {
  277. echo -e "$(tput setaf 10)\nChia-X-Proxy (Cuda):$(tput sgr0)"
  278. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/chia-x-proxy.tar.xz -O /home/wareck/Build_Cube/pack/chia-x-proxy.tar.xz
  279. cp /home/wareck/Build_Cube/pack/chia-x-proxy.tar.xz /home/wareck/
  280. cd /home/wareck/chia/
  281. tar xvfJ /home/wareck/chia-x-proxy.tar.xz
  282. rm /home/wareck/chia-x-proxy.tar.xz
  283. sleep 1
  284. cat <<'EOF'>> x-proxy.service
  285. [Unit]
  286. Description=x-proxy h9
  287. After=network.target
  288. StartLimitIntervalSec=500
  289. StartLimitBurst=5
  290. [Service]
  291. #Restart=on-failure
  292. #RestartSec=5s
  293. WorkingDirectory=/home/wareck/chia/x-proxy/
  294. User=wareck
  295. Group=adm
  296. ExecStart=/usr/bin/screen -DmS x-proxy /home/wareck/chia/x-proxy/x-proxy-v1.9.1 -config /home/wareck/chia/x-proxy/config.yaml
  297. ExecStop=/usr/bin/screen -S x-proxy -X quit
  298. LimitNOFILE=999999
  299. [Install]
  300. WantedBy=multi-user.target
  301. EOF
  302. sudo mv x-proxy.service /etc/systemd/system/x-proxy.service
  303. sudo systemctl daemon-reload
  304. sudo systemctl start x-proxy.service
  305. sudo systemctl enable x-proxy.service
  306. echo -e "\e[97mDone.\e[0m"
  307. }
  308. function service_old {
  309. echo -e "$(tput setaf 10)\nInstall chia-miner service (hpool) :$(tput sgr0)"
  310. sleep 1
  311. echo "Generation du fichier /etc/init.d/chia-miner"
  312. cat <<'EOF'>> chia-miner.sh
  313. #!/bin/sh
  314. ### BEGIN INIT INFO
  315. # Provides: chiaminer
  316. # Required-Start: networking
  317. # Default-Start: 3 4 5
  318. # Default-Stop: 0 6
  319. ### END INIT INFO
  320. case "$1" in
  321. start)
  322. if pgrep -x "hpool-miner-chia" > /dev/null
  323. then
  324. sudo killall -9 hpool-miner-chia | true
  325. fi
  326. su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config.yaml"
  327. ;;
  328. stop)
  329. if pgrep -x "hpool-miner-chia" > /dev/null
  330. then
  331. sudo killall -9 hpool-miner-chia | true
  332. fi
  333. ;;
  334. restart)
  335. $0 stop
  336. $0 start
  337. ;;
  338. *)
  339. echo "Usage: /etc/init.d/chia-miner {start|restart|stop}"
  340. exit 1
  341. ;;
  342. esac
  343. exit 0
  344. EOF
  345. chmod +x chia-miner.sh
  346. sudo cp chia-miner.sh /etc/init.d/chia-miner
  347. sudo update-rc.d chia-miner defaults
  348. sleep 1
  349. sudo /etc/init.d/chia-miner start
  350. sudo rm chia-miner.sh
  351. echo -e "\e[97mDone.\e[0m"
  352. }
  353. function service_ {
  354. echo -e "$(tput setaf 10)\nInstall chia-miner service (hpool) :$(tput sgr0)"
  355. sleep 1
  356. cat <<'EOF'>> chia-miner.service
  357. [Unit]
  358. Description=HPool miner
  359. After=network.target
  360. StartLimitIntervalSec=500
  361. StartLimitBurst=5
  362. [Service]
  363. #Restart=on-failure
  364. #RestartSec=5s
  365. WorkingDirectory=/home/wareck/miners/chia-miner/
  366. User=wareck
  367. Group=adm
  368. ExecStart=/usr/bin/screen -DmS hpool-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config.yaml
  369. ExecStop=/usr/bin/screen -S hpool-miner -X quit
  370. LimitNOFILE=999999
  371. [Install]
  372. WantedBy=multi-user.target
  373. EOF
  374. sudo mv chia-miner.service /etc/systemd/system/hpool-miner.service
  375. sudo systemctl daemon-reload
  376. sudo systemctl start hpool-miner.service
  377. sudo systemctl enable hpool-miner.service
  378. echo -e "\e[97mDone.\e[0m"
  379. }
  380. function cmake_ {
  381. if [ $BladeBit = "YES" ]
  382. then
  383. pids=""
  384. /home/wareck/Build_Cube/options/tools/_cmake.sh & pids="$pids $!"
  385. wait $pids
  386. fi
  387. }
  388. simplify_config
  389. intro_
  390. update_
  391. cmake_
  392. if [ $GigaHorse = "YES" ];then gigahorse;fi
  393. if [ $MadMax = "YES" ];then chia_plotter;fi
  394. if [ $BladeBit = "YES" ];then bladebit;fi
  395. if [ $ChiaPos = "YES" ];then chiapos;fi
  396. if [ $ChiaService = "YES" ];then service_;fi
  397. if [ $Miner = "YES" ];then miner_;fi
  398. if [ $ChiaProxy = "YES" ]; then chia_proxy;fi
  399. case $Gui in
  400. YES|ONLY)
  401. chia_blockchain
  402. ;;
  403. *)
  404. ;;
  405. esac
  406. echo -e "\n\e[97mEnd of process...\e[0m"