chia.sh 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. #!/bin/bash
  2. set -e
  3. Gui=Yes #can be Yes No or Only
  4. Service=No
  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 setaf 7)"
  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 setaf 7)"
  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 setaf 7)"
  50. fi
  51. if [ $Gui = "No" ]
  52. then
  53. echo -n "$(tput setaf 3)"
  54. print_centered "Chia Mining Enabled"
  55. echo -n "$(tput setaf 7)"
  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. echo -e "\e[97mDone.\e[0m"
  61. if ! [ $Gui = "Only" ]
  62. then
  63. echo -e "$(tput setaf 2)\nDownload pack:$(tput sgr0)"
  64. 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
  65. echo -e "$(tput setaf 2)\nBuild Chia-Miner:$(tput sgr0)"
  66. cp ../pack/chia-miner.tar.xz /home/wareck/miners
  67. cd /home/wareck/miners
  68. tar xvfJ chia-miner.tar.xz
  69. rm chia-miner.tar.xz
  70. if [ $Service = "Yes" ]
  71. then
  72. cat <<'EOF'>> chia-miner.sh
  73. #!/bin/sh -e
  74. ### BEGIN INIT INFO
  75. # Provides: chiaminer
  76. # Required-Start: networking
  77. # Default-Start: 3 4 5
  78. # Default-Stop: 0 6
  79. ### END INIT INFO
  80. case "$1" in
  81. start)
  82. cd /home/wareck/miners/chia-miner/
  83. #su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config.yaml"
  84. if ping -c 1 192.168.1.11
  85. then
  86. sleep 3
  87. su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config_proxy.yaml"
  88. else
  89. sleep 3
  90. su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config.yaml"
  91. fi
  92. ;;
  93. stop)
  94. sudo killall -9 hpool-miner-chia | true
  95. ;;
  96. *)
  97. echo "Usage: /etc/init.d/chia-miner {start|stop}"
  98. exit 1
  99. ;;
  100. esac
  101. exit 0
  102. EOF
  103. chmod +x chia-miner.sh
  104. sudo cp chia-miner.sh /etc/init.d/chia-miner
  105. sudo update-rc.d chia-miner defaults
  106. sudo rm chia-miner.sh
  107. fi
  108. echo -e "\e[97mDone.\e[0m"
  109. echo -e "$(tput setaf 2)\nBuild Chia-Plotter (MadMax) :$(tput sgr0)"
  110. cd /home/wareck
  111. if [ ! -d chia-plotter ]
  112. then
  113. git clone https://github.com/madMAx43v3r/chia-plotter.git
  114. else
  115. cd /home/wareck/chia-plotter
  116. git pull
  117. fi
  118. cd /home/wareck/chia-plotter
  119. git submodule init
  120. git submodule update
  121. ./make_devel.sh
  122. cd build
  123. cat <<'EOF'>> go.sh
  124. #!/bin/bash
  125. ./chia_plot -n 1 -r 4 -u 128 -t /media/Nvme/ -2 /media/Nvme/ -d /media/Partage/Plots/ -p a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  126. EOF
  127. chmod +x go.sh
  128. cat <<'EOF'>> nft.sh
  129. #!/bin/bash
  130. ./chia_plot -n 1 -r 4 -u 128 -t /media/Nvme/ -2 /media/Nvme/ -d /media/Partage/Plots-nft/ -c xch18c2jp56msc47yzww25wcnzz5fk9y268zl3zh357kftsp0n7l6m8scyqg4e -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  131. EOF
  132. chmod +x nft.sh
  133. echo -e "\e[97mDone.\e[0m"
  134. echo -e "$(tput setaf 2)\nBuild Chia-Pos:$(tput sgr0)"
  135. cd /home/wareck/
  136. if [ ! -d /home/wareck/chia-pos ]
  137. then
  138. git clone https://github.com/Chia-Network/chiapos.git chia-pos
  139. cd /home/wareck/chia-pos
  140. else
  141. cd /home/wareck/chia-pos
  142. git pull
  143. fi
  144. if [ ! -d build ]; then mkdir build;fi
  145. cd build
  146. cmake ..
  147. make -j4
  148. echo -e "\e[97mDone.\e[0m"
  149. fi
  150. if [ $Gui = "Yes" ] || [ $Gui = "Only" ]
  151. then
  152. echo -e "$(tput setaf 2)\nBuild Chia-Gui :$(tput sgr0)"
  153. cd /home/wareck
  154. if [ ! -d /home/wareck/chia-blockchain ]
  155. then
  156. git clone https://github.com/Chia-Network/chia-blockchain.git -b latest --recurse-submodules
  157. cd chia-blockchain
  158. else
  159. cd chia-blockchain
  160. git pull
  161. fi
  162. sh install.sh
  163. source ./activate
  164. sh install-gui.sh
  165. fi
  166. echo -e "$(tput setaf 2)\nChiaGiga Horse:$(tput sgr0)"
  167. if [ -d /home/wareck/chia-gigahorse ]
  168. then
  169. cd /home/wareck/chia-gigahorse
  170. git pull
  171. else
  172. cd /home/wareck/
  173. git clone https://github.com/madMAx43v3r/chia-gigahorse.git
  174. fi
  175. sudo cp ~/chia-gigahorse/plot-sink/linux/x86_64/* /usr/local/bin/
  176. sudo cp ~/chia-gigahorse/cpu-plotter/linux/x86_64/* /usr/local/bin/
  177. cd ~
  178. if [ -f distrib_chia.sh ];then rm distrib_chia.sh;fi
  179. if [ -f /usr/local/bin/distrib_chia.sh ];then rm /usr/local/bin/distrib_chia.sh;fi
  180. cat <<'EOF'>> distrib_chia.sh
  181. #!/bin/bash
  182. chia_plot_sink -p 1447 /Chia/Chia1/Plots-nft/ /Chia/Chia2/Plots-nft/ /Partage/Plots-nft/ /Cloud/Plots-nft/ /Store/Plots-nft/
  183. EOF
  184. chmod +x distrib_chia.sh
  185. sudo mv distrib_chia.sh /usr/local/bin/
  186. cat <<'EOF'>> cpu_chiagh_plot.sh
  187. #!/bin/bash
  188. chia_plot_k34 -M 8 -C 7 -n -1 -t /Nvme/plotting/ -d /Chia/Chia2/Plots-nft/ \
  189. -c xch10yjksfwm8s66z32qy35x950608hk8l67vmsur4rwpaanpkd6ks3qhfw5nk \
  190. -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  191. EOF
  192. chmod +x cpu_chiagh_plot.sh
  193. cp cpu_chiagh_plot.sh ~/chia-plotter/build/
  194. rm ~/cpu_chiagh_plot.sh
  195. echo -e "\n\e[97mEnd of process...\e[0m"