123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455 |
- #!/bin/bash
- set -e
- Version=6.1.2
- Gui=No #can be Yes No or Only
- GigaHorse_farmer=Yes
- MadMax=No
- GigaHorse=Yes
- BladeBit=No
- ChiaPos=no
- H9_ChiaService=No
- H9_Miner=No
- H9_ChiaProxy=No
- function print_centered {
- [[ $# == 0 ]] && return 1
- declare -i TERM_COLS="$(tput cols)"
- declare -i str_len="${#1}"
- [[ $str_len -ge $TERM_COLS ]] && {
- echo "$1";
- return 0;
- }
- declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
- [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
- filler=""
- for (( i = 0; i < filler_len; i++ )); do
- filler="${filler}${ch}"
- done
- printf "%s%s%s" "$filler" "$1" "$filler"
- [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
- printf "\n"
- return 0
- }
- #function jumpto
- #{
- # label=$1
- # cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$')
- # eval "$cmd"
- # exit
- #}
- function simplify_config {
- error_flag=0
- Gui=${Gui^^}
- H9_ChiaService=${H9_ChiaService^^}
- MadMax=${MadMax^^}
- GigaHorse=${GigaHorse^^}
- GigaHorse_farmer=${GigaHorse_farmer^^}
- BladeBit=${BladeBit^^}
- ChiaPos=${ChiaPos^^}
- H9_Miner=${H9_Miner^^}
- H9_ChiaProxy=${H9_ChiaProxy^^}
- if [[ "$Gui" == "YES" ]] || [[ "$Gui" == "NO" ]] || [[ "$Gui" == "ONLY" ]];then error_flag=$((error_flag+0));else error_flag=$((error_flag+1)) ;fi
- if [[ "$MadMax" == "YES" ]] || [[ "$MadMax" = "NO" ]];then error_flag=$((error_flag+0));else error_flag=$((error_flag+1)) ;fi
- if [[ "$GigaHorse" == "YES" ]] || [[ "$GigaHorse" == "NO" ]];then error_flag=$((error_flag+0));else error_flag=$((error_flag+1));fi
- if [[ "$GigaHorse_farmer" == "YES" ]] || [[ "$GigaHorse_farmer" == "NO" ]];then error_flag=$((error_flag+0));else error_flag=$((error_flag+1));fi
- if [[ "$BladeBit" == "YES" ]] || [[ "$BladeBit" == "NO" ]];then error_flag=$((error_flag+0));else error_flag=$((error_flag+1));fi
- if [[ "$ChiaPos" == "YES" ]] || [[ "$ChiaPos" == "NO" ]];then error_flag=$((error_flag+0));else error_flag=$((error_flag+1));fi
- if [[ "$H9_ChiaService" == "YES" ]] || [[ "$H9_ChiaService" == "NO" ]];then error_flag=$((error_flag+0));else error_flag=$((error_flag+1));fi
- if [[ "$H9_Miner" == "YES" ]] || [[ "$H9_Miner" == "NO" ]];then error_flag=$((error_flag+0));else error_flag=$((error_flag+1));fi
- if [[ "$H9_ChiaProxy" == "YES" ]] || [[ "$H9_ChiaProxy" == "NO" ]];then error_flag=$((error_flag+0));else error_flag=$((error_flag+1));fi
- }
- function intro_ {
- export TERM=xterm-256color
- print_centered "$(tput setaf 10)"
- print_centered " ______ __ __ "
- print_centered "| | |--.|__|.---.-."
- print_centered "| ---| || || _ |"
- print_centered "|______|__|__||__||___._|"
- echo -n "$(tput sgr0)"
- print_centered "Toolkit for Chia v$Version"
- echo ""
- if [ $error_flag -ne 0 ]
- then
- echo -n "$(tput setaf 1 ;tput blink;tput bold)"
- print_centered "Config Error !!! $error_flag"
- echo -n "$(tput sgr0)"
- exit 0
- fi
- case $Gui in
- YES)
- echo -n "$(tput setaf 40)"
- print_centered "Blockchain wallet + Gui"
- echo -n "$(tput sgr0)"
- echo -n "$(tput setaf 11)"
- print_centered "Chia Plotting Tools"
- echo -n "$(tput sgr0)"
- ;;
- NO)
- echo -n "$(tput setaf 11)"
- print_centered "Chia Plotting Tools"
- echo -n "$(tput sgr0)"
- ;;
- ONLY)
- echo -n "$(tput setaf 41)"
- print_centered "Blockchain + GUI wallet Only"
- echo -n "$(tput sgr0)"
- ;;
- *)
- echo -n "$(tput setaf 1 ;tput blink;tput bold)"
- print_centered "Config Error !!!"
- echo -n "$(tput sgr0)"
- exit 0
- ;;
- esac
- if [ $Gui = "NO" ] || [ $Gui = "YES" ]
- then
- case $GigaHorse_farmer in
- YES)
- echo -n "$(tput setaf 42)"
- print_centered "GigaHorse Farmer"
- echo -n "$(tput sgr0)"
- ;;
- esac
- case $H9_ChiaService in
- YES)
- echo -n "$(tput setaf 43)"
- print_centered "Mining service Enabled"
- echo -n "$(tput sgr0)"
- ;;
- esac
- case $H9_ChiaProxy in
- YES)
- echo -n "$(tput setaf 43)"
- print_centered "Hpool x-Proxy Enabled"
- echo -n "$(tput sgr0)"
- ;;
- esac
- fi
- sleep 2
- if ! [ -d /home/wareck/chia ];then mkdir /home/wareck/chia;fi
- }
- function GigaHorse_farmer_ {
- echo -e "$(tput setaf 10)\nInstall GigaHorse Farmer$(tput sgr0)"
- if ! [ -d /home/wareck/blockchain ];then mkdir /home/wareck/blockchain;fi
- cd /home/wareck/blockchain/
- NAME=$(curl -s https://api.github.com/repos/madMAx43v3r/chia-gigahorse/releases/latest | grep ".*x86_64.tar.gz" | grep "name" | awk {'print$2'} | cut -d : -f 2,3 | tr -d \",| grep -v "h100")
- curl -s https://api.github.com/repos/madMAx43v3r/chia-gigahorse/releases/latest | grep "browser_download_url.*-x86_64.tar.gz" | cut -d : -f 2,3 | tr -d \" |grep -v "h100"| wget -q --show-progress -i -
- tar xfz $NAME --checkpoint=.1000
- rm $NAME
- echo -e "\n\e[97mDone.\e[0m"
- }
- function update_ {
- echo -e "$(tput setaf 10)\nUpdate and install packages:$(tput sgr0)"
- extend="libgomp1 ocl-icd-opencl-dev libgmp-dev libnuma-dev"
- sudo apt-get install python3-venv python3-distutils python3-dev libsodium-dev $extend -y
- echo -e "\e[97mDone.\e[0m"
- }
- function chia_plotter {
- echo -e "$(tput setaf 10)\nBuild Chia-Plotter (MadMax4ever) :$(tput sgr0)"
- sleep 1
- cd /home/wareck/chia/
- if [ ! -d chia-plotter ]
- then
- git clone https://github.com/madMAx43v3r/chia-plotter.git
- else
- cd /home/wareck/chia/chia-plotter
- git pull
- fi
- cd /home/wareck/chia/chia-plotter
- git submodule init
- git submodule update
- ./make_devel.sh
- cd build
- if [ -f go.sh ];then rm go.sh ;fi
- cat <<'EOF'>> go.sh
- #!/bin/bash
- POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
- FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
- OUT=/media/Partage/Plots/
- ./chia_plot -p $POOL -f $FARM -n 1 -r 6 -u 128 -t /nvme0/plotting/ -2 /nvme0/plotting/ -d $OUT
- EOF
- chmod +x go.sh
- echo -e "\e[97mDone.\e[0m"
- }
- function bladebit {
- echo -e "$(tput setaf 10)\nBuild Bladebit v2 :$(tput sgr0)"
- sleep 1
- cd /home/wareck/chia
- if [ ! -d bladebit ]
- then
- git clone https://github.com/Chia-Network/bladebit.git
- fi
- cd /home/wareck/chia/bladebit/
- if [ ! -d build ];then mkdir build;fi
- cd build
- sed -i "s/FatalIf( cfg.compressionLevel >/\/\/FatalIf( cfg.compressionLevel/g" /home/wareck/chia/bladebit/src/main.cpp
- cmake ..
- make -j 6
- if [ -f cuda.sh ]; then rm cuda.sh ;fi
- cat <<'EOF'>> cuda.sh
- #!/bin/bash
- POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
- FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
- OUT=/farm/farm0/Plots
- for i in {1..5}
- do
- ./bladebit_cuda --no-direct-io -p $POOL -f $FARM -z 7 cudaplot -d 0 --disk-16 -t1 /raid/plotting $OUT
- done
- EOF
- chmod +x cuda.sh
- echo -e "\e[97mDone.\e[0m"
- }
- function gigahorse {
- echo -e "$(tput setaf 10)\nMadMax4ever GigaHorse:$(tput sgr0)"
- sleep 1
- if [ -d /home/wareck/chia/chia-gigahorse ]
- then
- cd /home/wareck/chia/chia-gigahorse
- git pull
- else
- cd /home/wareck/chia/
- git clone https://github.com/madMAx43v3r/chia-gigahorse.git
- fi
- echo "generate bash files..."
- sudo cp ~/chia/chia-gigahorse/plot-sink/linux/x86_64/* /usr/local/bin/
- sudo cp ~/chia/chia-gigahorse/cpu-plotter/linux/x86_64/* /usr/local/bin/
- sudo cp ~/chia/chia-gigahorse/chiapos/linux/x86_64/ProofOfSpace /usr/local/bin/
- cd ~
- if [ -f distrib_chia.sh ];then sudo rm distrib_chia.sh;fi
- if [ -f /usr/local/bin/distrib_chia.sh ];then sudo rm /usr/local/bin/distrib_chia.sh;fi
- cat <<'EOF'>> distrib_chia.sh
- #!/bin/bash
- echo "IP : $(hostname -I)"
- chia_plot_sink /farm/farm0/Plots/ /farm/farm1/Plots/ /farm/farm2/Plots/ /farm/farm3/Plots/ /farm/farm4/Plots/ /Partage/Plots/
- EOF
- chmod +x distrib_chia.sh
- sudo mv distrib_chia.sh /usr/local/bin/
- if [ -f go.sh ];then rm go.sh;fi
- cat <<'EOF'>> ~/go.sh
- #!/bin/bash
- CRT=xch10yjksfwm8s66z32qy35x950608hk8l67vmsur4rwpaanpkd6ks3qhfw5nk
- FRM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
- OUT=@192.168.1.100
- ./chia_plot -c $CRT -f $FRM -G -r 6 -z 1447 -C 8 -n -1 -t /nvme0/plotting/ -2 /nvme1/plotting/ -d $OUT
- EOF
- chmod +x ~/go.sh
- cp ~/go.sh ~/chia/chia-gigahorse/cpu-plotter/linux/x86_64/
- rm ~/go.sh
- echo -e "\e[97mDone.\e[0m"
- }
- function chiapos {
- echo -e "$(tput setaf 10)\nBuild Chia-Pos:$(tput sgr0)"
- sleep 1
- cd /home/wareck/chia
- if [ ! -d /home/wareck/chia/chia-pos ]
- then
- git clone https://github.com/Chia-Network/chiapos.git chia-pos
- cd /home/wareck/chia/chia-pos
- else
- cd /home/wareck/chia/chia-pos
- git pull
- fi
- if [ ! -d build ]; then mkdir build;fi
- cd build
- cmake ..
- cmake --build . -- -j 6
- echo -e "\e[97mDone.\e[0m"
- }
- function miner_ {
- echo -e "$(tput setaf 10)\nChia-Miner (hpool):$(tput sgr0)"
- sleep 1
- 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
- cp /home/wareck/Build_Cube/pack/chia-miner.tar.xz /home/wareck/miners
- cd /home/wareck/miners
- tar xvfJ chia-miner.tar.xz
- rm chia-miner.tar.xz
- echo -e "\e[97mDone.\e[0m"
- }
- function chia_blockchain {
- echo -e "$(tput setaf 10)\nBuild Chia-blockchain & Gui :$(tput sgr0)"
- sleep 1
- if ! [ -d /home/wareck/blockchain ];then mkdir /home/wareck/blockchain;fi
- cd /home/wareck/blockchain
- if [ ! -d /home/wareck/blockchain/chia-blockchain ]
- then
- git clone https://github.com/Chia-Network/chia-blockchain.git -b latest --recurse-submodules
- cd chia-blockchain
- else
- cd chia-blockchain
- git pull
- fi
- sh install.sh
- source ./activate
- sh install-gui.sh
- #if [ -f /Store/.chia ]
- #then
- #ln -s /Store/.chia /home/wareck/.chia
- #ln -s /Store/.chia_keys /home/wareck/.chia_keys
- #fi
- echo -e "\e[97mDone.\e[0m"
- }
- function chia_proxy {
- echo -e "$(tput setaf 10)\nChia-X-Proxy (Cuda):$(tput sgr0)"
- 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
- cp /home/wareck/Build_Cube/pack/chia-x-proxy.tar.xz /home/wareck/
- cd /home/wareck/chia/
- tar xvfJ /home/wareck/chia-x-proxy.tar.xz
- rm /home/wareck/chia-x-proxy.tar.xz
- sleep 1
- cat <<'EOF'>> x-proxy.service
- [Unit]
- Description=x-proxy
- After=network.target
- StartLimitIntervalSec=500
- StartLimitBurst=5
- [Service]
- #Restart=on-failure
- #RestartSec=5s
- WorkingDirectory=/home/wareck/chia/x-proxy/
- User=wareck
- Group=adm
- 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
- ExecStop=/usr/bin/screen -S x-proxy -X quit
- LimitNOFILE=999999
- [Install]
- WantedBy=multi-user.target
- EOF
- sudo mv x-proxy.service /etc/systemd/system/x-proxy.service
- sudo systemctl daemon-reload
- sudo systemctl start x-proxy.service
- sudo systemctl enable x-proxy.service
- echo -e "\e[97mDone.\e[0m"
- }
- function service_old {
- echo -e "$(tput setaf 10)\nInstall chia-miner service (hpool) :$(tput sgr0)"
- sleep 1
- echo "Generation du fichier /etc/init.d/chia-miner"
- cat <<'EOF'>> chia-miner.sh
- #!/bin/sh
- ### BEGIN INIT INFO
- # Provides: chiaminer
- # Required-Start: networking
- # Default-Start: 3 4 5
- # Default-Stop: 0 6
- ### END INIT INFO
- case "$1" in
- start)
- if pgrep -x "hpool-miner-chia" > /dev/null
- then
- sudo killall -9 hpool-miner-chia | true
- fi
- su wareck -c "screen -dmS chia-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config.yaml"
- ;;
- stop)
- if pgrep -x "hpool-miner-chia" > /dev/null
- then
- sudo killall -9 hpool-miner-chia | true
- fi
- ;;
- restart)
- $0 stop
- $0 start
- ;;
- *)
- echo "Usage: /etc/init.d/chia-miner {start|restart|stop}"
- exit 1
- ;;
- esac
- exit 0
- EOF
- chmod +x chia-miner.sh
- sudo cp chia-miner.sh /etc/init.d/chia-miner
- sudo update-rc.d chia-miner defaults
- sleep 1
- sudo /etc/init.d/chia-miner start
- sudo rm chia-miner.sh
- echo -e "\e[97mDone.\e[0m"
- }
- function service_ {
- echo -e "$(tput setaf 10)\nInstall chia-miner service (hpool) :$(tput sgr0)"
- sleep 1
- cat <<'EOF'>> chia-miner.service
- [Unit]
- Description=HPool miner
- After=network.target
- StartLimitIntervalSec=500
- StartLimitBurst=5
- [Service]
- #Restart=on-failure
- #RestartSec=5s
- WorkingDirectory=/home/wareck/miners/chia-miner/
- User=wareck
- Group=adm
- ExecStart=/usr/bin/screen -DmS hpool-miner /home/wareck/miners/chia-miner/hpool-miner-chia -config /home/wareck/miners/chia-miner/config.yaml
- ExecStop=/usr/bin/screen -S hpool-miner -X quit
- LimitNOFILE=999999
- [Install]
- WantedBy=multi-user.target
- EOF
- sudo mv chia-miner.service /etc/systemd/system/hpool-miner.service
- sudo systemctl daemon-reload
- sudo systemctl start hpool-miner.service
- sudo systemctl enable hpool-miner.service
- echo -e "\e[97mDone.\e[0m"
- }
- function cmake_ {
- if [ $BladeBit = "YES" ]
- then
- pids=""
- /home/wareck/Build_Cube/options/tools/_cmake.sh & pids="$pids $!"
- wait $pids
- fi
- }
- simplify_config
- intro_
- update_
- cmake_
- case $Gui in
- ONLY)
- chia_blockchain
- ;;
- *)
- if [ $GigaHorse = "YES" ];then gigahorse;fi
- if [ $MadMax = "YES" ];then chia_plotter;fi
- if [ $BladeBit = "YES" ];then bladebit;fi
- if [ $ChiaPos = "YES" ];then chiapos;fi
- if [ $H9_Miner = "YES" ];then miner_;fi
- if [ $H9_ChiaService = "YES" ];then service_;fi
- if [ $H9_ChiaProxy = "YES" ]; then chia_proxy;fi
- if [ $GigaHorse_farmer = "YES" ];then GigaHorse_farmer_;fi
- if [ $Gui = "YES" ]; then chia_blockchain;fi
- ;;
- esac
- echo -e "\n\e[97mEnd of process...\e[0m"
|