chia.sh 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. cd /home/wareck/miners/chia-miner/
  79. #su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config.yaml"
  80. if ping -c 1 192.168.1.11
  81. then
  82. sleep 3
  83. su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config_proxy.yaml"
  84. else
  85. sleep 3
  86. su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config.yaml"
  87. fi
  88. exit 0
  89. EOF
  90. chmod +x chia-miner.sh
  91. sudo cp chia-miner.sh /etc/init.d/chia-miner
  92. sudo update-rc.d chia-miner defaults
  93. sudo rm chia-miner.sh
  94. echo -e "\e[97mDone.\e[0m"
  95. echo -e "$(tput setaf 2)\nBuild Chia-Plotter (MadMax) :$(tput sgr0)"
  96. cd /home/wareck
  97. if [ ! -d chia-plotter ]
  98. then
  99. git clone https://github.com/madMAx43v3r/chia-plotter.git
  100. else
  101. cd /home/wareck/chia-plotter
  102. git pull
  103. fi
  104. cd /home/wareck/chia-plotter
  105. git submodule init
  106. git submodule update
  107. ./make_devel.sh
  108. cd build
  109. cat <<'EOF'>> go.sh
  110. #!/bin/bash
  111. ./chia_plot -n 1 -r 4 -u 128 -t /media/Nvme/ -2 /media/Nvme/ -d /media/Partage/Plots/ -p a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  112. EOF
  113. chmod +x go.sh
  114. cat <<'EOF'>> nft.sh
  115. #!/bin/bash
  116. ./chia_plot -n 1 -r 4 -u 128 -t /media/Nvme/ -2 /media/Nvme/ -d /media/Partage/Plots-nft/ -c xch18c2jp56msc47yzww25wcnzz5fk9y268zl3zh357kftsp0n7l6m8scyqg4e -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  117. EOF
  118. chmod +x nft.sh
  119. echo -e "\e[97mDone.\e[0m"
  120. cat <<'EOF'>> flexpool.sh
  121. #!/bin/bash
  122. ./chia_plot -n 1 -r 4 -u 128 -t /media/Nvme/ -2 /media/Nvme/ -d /Chia/Chia1/Plots-nft/ -c xch10yjksfwm8s66z32qy35x950608hk8l67vmsur4rwpaanpkd6ks3qhfw5nk -f 8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  123. EOF
  124. chmod +x flexpool.sh
  125. echo -e "\e[97mDone.\e[0m"
  126. echo -e "$(tput setaf 2)\nBuild Chia-Pos:$(tput sgr0)"
  127. cd /home/wareck/
  128. if [ ! -d /home/wareck/chia-pos ]
  129. then
  130. git clone https://github.com/Chia-Network/chiapos.git chia-pos
  131. cd /home/wareck/chia-pos
  132. else
  133. cd /home/wareck/chia-pos
  134. git pull
  135. fi
  136. if [ ! -d build ]; then mkdir build;fi
  137. cd build
  138. cmake ..
  139. make -j4
  140. echo -e "\e[97mDone.\e[0m"
  141. fi
  142. if [ $Gui = "Yes" ] || [ $Gui = "Only" ]
  143. then
  144. echo -e "$(tput setaf 2)\nBuild Chia-Gui :$(tput sgr0)"
  145. cd /home/wareck
  146. if [ ! -d /home/wareck/chia-blockchain ]
  147. then
  148. git clone https://github.com/Chia-Network/chia-blockchain.git -b latest --recurse-submodules
  149. cd chia-blockchain
  150. else
  151. cd chia-blockchain
  152. git pull
  153. fi
  154. sh install.sh
  155. source ./activate
  156. sh install-gui.sh
  157. fi
  158. echo -e "\n\e[97mEnd of process...\e[0m"