chia.sh 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. #!/bin/bash
  2. set -e
  3. Gui=No #can be Yes No or Only
  4. Service=Yes
  5. Version=3.0
  6. function print_centered {
  7. [[ $# == 0 ]] && return 1
  8. declare -i TERM_COLS="$(tput cols)"
  9. declare -i str_len="${#1}"
  10. [[ $str_len -ge $TERM_COLS ]] && {
  11. echo "$1";
  12. return 0;
  13. }
  14. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  15. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  16. filler=""
  17. for (( i = 0; i < filler_len; i++ )); do
  18. filler="${filler}${ch}"
  19. done
  20. printf "%s%s%s" "$filler" "$1" "$filler"
  21. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  22. printf "\n"
  23. return 0
  24. }
  25. function jumpto
  26. {
  27. label=$1
  28. cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$')
  29. eval "$cmd"
  30. exit
  31. }
  32. print_centered "$(tput setaf 10)"
  33. print_centered " ______ __ __ "
  34. print_centered "| | |--.|__|.---.-."
  35. print_centered "| ---| || || _ |"
  36. print_centered "|______|__|__||__||___._|"
  37. echo -n "$(tput sgr0)"
  38. print_centered "Toolkit for Chia v$Version"
  39. if [ $Gui = "Yes" ]
  40. then
  41. echo -n "$(tput setaf 3)"
  42. print_centered "Chia Gui + mining Enabled"
  43. echo -n "$(tput sgr0)"
  44. fi
  45. if [ $Gui = "Only" ]
  46. then
  47. echo -n "$(tput setaf 3)"
  48. print_centered "Chia blockchain Gui Only"
  49. echo -n "$(tput sgr0)"
  50. fi
  51. if [ $Gui = "No" ]
  52. then
  53. echo -n "$(tput setaf 3)"
  54. print_centered "Chia Mining Enabled"
  55. echo -n "$(tput sgr0)"
  56. fi
  57. sleep 3
  58. echo -e "$(tput setaf 2)\nUpdate and install packages:$(tput sgr0)"
  59. sudo apt-get install python3-venv python3-distutils python3-dev libsodium-dev -y
  60. if grep "Drivers=NVIDIA" ../build_cube.sh >/dev/null
  61. then
  62. sudo apt install libgomp1 ocl-icd-opencl-dev -y
  63. fi
  64. echo -e "\e[97mDone.\e[0m"
  65. if ! [ $Gui = "Only" ]
  66. then
  67. echo -e "$(tput setaf 2)\nDownload pack:$(tput sgr0)"
  68. 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
  69. echo -e "$(tput setaf 2)\nBuild Chia-Miner:$(tput sgr0)"
  70. cp ../pack/chia-miner.tar.xz /home/wareck/miners
  71. cd /home/wareck/miners
  72. tar xvfJ chia-miner.tar.xz
  73. rm chia-miner.tar.xz
  74. if [ $Service = "Yes" ]
  75. then
  76. cat <<'EOF'>> chia-miner.sh
  77. #!/bin/sh -e
  78. ### BEGIN INIT INFO
  79. # Provides: chiaminer
  80. # Required-Start: networking
  81. # Default-Start: 3 4 5
  82. # Default-Stop: 0 6
  83. ### END INIT INFO
  84. case "$1" in
  85. start)
  86. cd /home/wareck/miners/chia-miner/
  87. #su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config.yaml"
  88. if ping -c 1 192.168.1.11
  89. then
  90. sleep 3
  91. su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config_proxy.yaml"
  92. else
  93. sleep 3
  94. su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config.yaml"
  95. fi
  96. ;;
  97. stop)
  98. sudo killall -9 hpool-miner-chia | true
  99. ;;
  100. *)
  101. echo "Usage: /etc/init.d/chia-miner {start|stop}"
  102. exit 1
  103. ;;
  104. esac
  105. exit 0
  106. EOF
  107. chmod +x chia-miner.sh
  108. sudo cp chia-miner.sh /etc/init.d/chia-miner
  109. sudo update-rc.d chia-miner defaults
  110. sudo rm chia-miner.sh
  111. fi
  112. echo -e "\e[97mDone.\e[0m"
  113. echo -e "$(tput setaf 2)\nBuild Chia-Plotter (MadMax) :$(tput sgr0)"
  114. cd /home/wareck
  115. if [ ! -d chia-plotter ]
  116. then
  117. git clone https://github.com/madMAx43v3r/chia-plotter.git
  118. else
  119. cd /home/wareck/chia-plotter
  120. git pull
  121. fi
  122. cd /home/wareck/chia-plotter
  123. git submodule init
  124. git submodule update
  125. ./make_devel.sh
  126. cd build
  127. cat <<'EOF'>> go.sh
  128. #!/bin/bash
  129. ./chia_plot -n 1 -r 4 -u 128 -t /media/Nvme/ -2 /media/Nvme/ -d /media/Partage/Plots/ -p a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  130. EOF
  131. chmod +x go.sh
  132. cat <<'EOF'>> nft.sh
  133. #!/bin/bash
  134. ./chia_plot -n 1 -r 4 -u 128 -t /media/Nvme/ -2 /media/Nvme/ -d /media/Partage/Plots-nft/ -c xch18c2jp56msc47yzww25wcnzz5fk9y268zl3zh357kftsp0n7l6m8scyqg4e -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  135. EOF
  136. chmod +x nft.sh
  137. echo -e "\e[97mDone.\e[0m"
  138. echo -e "$(tput setaf 2)\nBuild Chia-Pos:$(tput sgr0)"
  139. cd /home/wareck/
  140. if [ ! -d /home/wareck/chia-pos ]
  141. then
  142. git clone https://github.com/Chia-Network/chiapos.git chia-pos
  143. cd /home/wareck/chia-pos
  144. else
  145. cd /home/wareck/chia-pos
  146. git pull
  147. fi
  148. if [ ! -d build ]; then mkdir build;fi
  149. cd build
  150. cmake ..
  151. make -j6
  152. echo -e "\e[97mDone.\e[0m"
  153. fi
  154. if [ $Gui = "Yes" ] || [ $Gui = "Only" ]
  155. then
  156. echo -e "$(tput setaf 2)\nBuild Chia-Gui :$(tput sgr0)"
  157. cd /home/wareck
  158. if [ ! -d /home/wareck/chia-blockchain ]
  159. then
  160. git clone https://github.com/Chia-Network/chia-blockchain.git -b latest --recurse-submodules
  161. cd chia-blockchain
  162. else
  163. cd chia-blockchain
  164. git pull
  165. fi
  166. sh install.sh
  167. source ./activate
  168. sh install-gui.sh
  169. fi
  170. echo -e "$(tput setaf 2)\nChiaGiga Horse:$(tput sgr0)"
  171. if [ -d /home/wareck/chia-gigahorse ]
  172. then
  173. cd /home/wareck/chia-gigahorse
  174. git pull
  175. else
  176. cd /home/wareck/
  177. git clone https://github.com/madMAx43v3r/chia-gigahorse.git
  178. fi
  179. sudo cp ~/chia-gigahorse/plot-sink/linux/x86_64/* /usr/local/bin/
  180. sudo cp ~/chia-gigahorse/cpu-plotter/linux/x86_64/* /usr/local/bin/
  181. cd ~
  182. if [ -f distrib_chia.sh ];then sudo rm distrib_chia.sh;fi
  183. if [ -f /usr/local/bin/distrib_chia.sh ];then sudo rm /usr/local/bin/distrib_chia.sh;fi
  184. cat <<'EOF'>> distrib_chia.sh
  185. #!/bin/bash
  186. echo "IP : $(hostname -I)"
  187. chia_plot_sink -p 1447 /Chia/Chia1/Plots-nft/ /Chia/Chia2/Plots-nft/ /Chia/Chia3/Plots-nft/ /Partage/Plots-nft/ /Cloud/Plots-nft/ /Store/Plots-nft/ /Exos/Plots-nft
  188. EOF
  189. chmod +x distrib_chia.sh
  190. sudo mv distrib_chia.sh /usr/local/bin/
  191. cat <<'EOF'>> ~/go.sh
  192. #!/bin/bash
  193. ./chia_plot -G -z 1447 -C 8 -n -1 -t /Nvme0/plotting/ -2 /Nvme1/plotting/ -d @192.168.1.100 \
  194. -c xch10yjksfwm8s66z32qy35x950608hk8l67vmsur4rwpaanpkd6ks3qhfw5nk \
  195. -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  196. EOF
  197. chmod +x ~/go.sh
  198. cp ~/go.sh ~/chia-gigahorse/cpu-plotter/linux/x86_64/
  199. rm ~/go.sh
  200. echo -e "\n\e[97mEnd of process...\e[0m"