chia.sh 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #!/bin/bash
  2. set -e
  3. Gui=Yes #can be Yes No or Only
  4. Version=2.3
  5. function print_centered {
  6. [[ $# == 0 ]] && return 1
  7. declare -i TERM_COLS="$(tput cols)"
  8. declare -i str_len="${#1}"
  9. [[ $str_len -ge $TERM_COLS ]] && {
  10. echo "$1";
  11. return 0;
  12. }
  13. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  14. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  15. filler=""
  16. for (( i = 0; i < filler_len; i++ )); do
  17. filler="${filler}${ch}"
  18. done
  19. printf "%s%s%s" "$filler" "$1" "$filler"
  20. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  21. printf "\n"
  22. return 0
  23. }
  24. function jumpto
  25. {
  26. label=$1
  27. cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$')
  28. eval "$cmd"
  29. exit
  30. }
  31. print_centered "$(tput setaf 10)"
  32. print_centered " ______ __ __ "
  33. print_centered "| | |--.|__|.---.-."
  34. print_centered "| ---| || || _ |"
  35. print_centered "|______|__|__||__||___._|"
  36. echo -n "$(tput setaf 7)"
  37. print_centered "Toolkit for Chia v$Version"
  38. if [ $Gui = "Yes" ]
  39. then
  40. echo -n "$(tput setaf 3)"
  41. print_centered "Chia Gui + mining Enabled"
  42. echo -n "$(tput setaf 7)"
  43. fi
  44. if [ $Gui = "Only" ]
  45. then
  46. echo -n "$(tput setaf 3)"
  47. print_centered "Chia blockchain Gui Only"
  48. echo -n "$(tput setaf 7)"
  49. fi
  50. if [ $Gui = "No" ]
  51. then
  52. echo -n "$(tput setaf 3)"
  53. print_centered "Chia Mining Enabled"
  54. echo -n "$(tput setaf 7)"
  55. fi
  56. sleep 3
  57. echo -e "$(tput setaf 2)\nUpdate and install packages:$(tput sgr0)"
  58. sudo apt-get install python3-venv python3-distutils python3-dev libsodium-dev -y
  59. echo -e "\e[97mDone.\e[0m"
  60. if ! [ $Gui = "Only" ]
  61. then
  62. echo -e "$(tput setaf 2)\nDownload pack:$(tput sgr0)"
  63. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/chia-miner.tar.xz
  64. mv chia-miner.tar.xz /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. cat <<'EOF'>> chia-miner.sh
  71. #!/bin/sh -e
  72. ### BEGIN INIT INFO
  73. # Provides: chiaminer
  74. # Required-Start: networking
  75. # Default-Start: 3 4 5
  76. # Default-Stop: 0 6
  77. ### END INIT INFO
  78. case "$1" in
  79. start)
  80. cd /home/wareck/miners/chia-miner/
  81. #su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config.yaml"
  82. if ping -c 1 192.168.1.11
  83. then
  84. sleep 3
  85. su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config_proxy.yaml"
  86. else
  87. sleep 3
  88. su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config.yaml"
  89. fi
  90. ;;
  91. stop)
  92. sudo killall -9 hpool-miner-chia | true
  93. ;;
  94. *)
  95. echo "Usage: /etc/init.d/chia-miner {start|stop}"
  96. exit 1
  97. ;;
  98. esac
  99. exit 0
  100. EOF
  101. chmod +x chia-miner.sh
  102. sudo cp chia-miner.sh /etc/init.d/chia-miner
  103. sudo update-rc.d chia-miner defaults
  104. sudo rm chia-miner.sh
  105. echo -e "\e[97mDone.\e[0m"
  106. echo -e "$(tput setaf 2)\nBuild Chia-Plotter (MadMax) :$(tput sgr0)"
  107. cd /home/wareck
  108. if [ ! -d chia-plotter ]
  109. then
  110. git clone https://github.com/madMAx43v3r/chia-plotter.git
  111. else
  112. cd /home/wareck/chia-plotter
  113. git pull
  114. fi
  115. cd /home/wareck/chia-plotter
  116. git submodule init
  117. git submodule update
  118. ./make_devel.sh
  119. cd build
  120. cat <<'EOF'>> go.sh
  121. #!/bin/bash
  122. ./chia_plot -n 1 -r 4 -u 128 -t /media/Nvme/ -2 /media/Nvme/ -d /media/Partage/Plots/ -p a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  123. EOF
  124. chmod +x go.sh
  125. cat <<'EOF'>> nft.sh
  126. #!/bin/bash
  127. ./chia_plot -n 1 -r 4 -u 128 -t /media/Nvme/ -2 /media/Nvme/ -d /media/Partage/Plots-nft/ -c xch18c2jp56msc47yzww25wcnzz5fk9y268zl3zh357kftsp0n7l6m8scyqg4e -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  128. EOF
  129. chmod +x nft.sh
  130. echo -e "\e[97mDone.\e[0m"
  131. cat <<'EOF'>> flexpool.sh
  132. #!/bin/bash
  133. ./chia_plot -n 1 -r 4 -u 128 -t /media/Nvme/Plotting -2 /media/Nvme/Plotting -d /Chia/Chia1/Plots-nft/ -c xch10yjksfwm8s66z32qy35x950608hk8l67vmsur4rwpaanpkd6ks3qhfw5nk -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  134. EOF
  135. chmod +x flexpool.sh
  136. echo -e "\e[97mDone.\e[0m"
  137. echo -e "$(tput setaf 2)\nBuild Chia-Pos:$(tput sgr0)"
  138. cd /home/wareck/
  139. if [ ! -d /home/wareck/chia-pos ]
  140. then
  141. git clone https://github.com/Chia-Network/chiapos.git chia-pos
  142. cd /home/wareck/chia-pos
  143. else
  144. cd /home/wareck/chia-pos
  145. git pull
  146. fi
  147. if [ ! -d build ]; then mkdir build;fi
  148. cd build
  149. cmake ..
  150. make -j4
  151. echo -e "\e[97mDone.\e[0m"
  152. fi
  153. if [ $Gui = "Yes" ] || [ $Gui = "Only" ]
  154. then
  155. echo -e "$(tput setaf 2)\nBuild Chia-Gui :$(tput sgr0)"
  156. cd /home/wareck
  157. if [ ! -d /home/wareck/chia-blockchain ]
  158. then
  159. git clone https://github.com/Chia-Network/chia-blockchain.git -b latest --recurse-submodules
  160. cd chia-blockchain
  161. else
  162. cd chia-blockchain
  163. git pull
  164. fi
  165. sh install.sh
  166. source ./activate
  167. sh install-gui.sh
  168. fi
  169. echo -e "\n\e[97mEnd of process...\e[0m"