foxy-pool.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #!/bin/bash
  2. FoxyPool_service=Yes
  3. FoxyPool_service=${FoxyPool_service^^}
  4. if [ -f /tmp/latest ]; then rm /tmp/latest ; fi
  5. curl -s https://api.github.com/repos/foxypool/foxy-gh-farmer/releases/latest > /tmp/latest
  6. VERSION=$(cat /tmp/latest | grep "tag_name" | awk {'print$2'} | tr -d \",)
  7. URL=$(cat /tmp//latest |grep "browser_download_url.*ubuntu.zip" | cut -d : -f 2,3 | tr -d \")
  8. if [[ "$FoxyPool_service" == "YES" ]] || [[ "$FoxyPool_service" == "NO" ]];then error_flag=$((error_flag+0));else error_flag=$((error_flag+1));fi
  9. function print_centered {
  10. [[ $# == 0 ]] && return 1
  11. declare -i TERM_COLS="$(tput cols)"
  12. declare -i str_len="${#1}"
  13. [[ $str_len -ge $TERM_COLS ]] && {
  14. echo "$1";
  15. return 0;
  16. }
  17. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  18. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  19. filler=""
  20. for (( i = 0; i < filler_len; i++ )); do
  21. filler="${filler}${ch}"
  22. done
  23. printf "%s%s%s" "$filler" "$1" "$filler"
  24. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  25. printf "\n"
  26. return 0
  27. }
  28. export TERM=xterm-256color
  29. print_centered "$(tput setaf 130)"
  30. print_centered " _____ _ "
  31. print_centered "| __|___ _ _ _ _ ___ ___ ___| |"
  32. print_centered "| __| . |_'_| | | . | . | . | |"
  33. print_centered "|__| |___|_,_|_ | _|___|___|_|"
  34. print_centered " |___|_| "
  35. print_centered ""
  36. echo -n "$(tput sgr0)"
  37. print_centered "Version $VERSION"
  38. if [ $error_flag -ne 0 ]
  39. then
  40. echo -n "$(tput setaf 1 ;tput bold)"
  41. print_centered "Config Error !!!"
  42. echo -n "$(tput sgr0)"
  43. exit 0
  44. fi
  45. case $FoxyPool_service in
  46. YES)
  47. echo -n "$(tput setaf 44)"
  48. print_centered "FoxyPool Service Enabled"
  49. echo -n "$(tput sgr0)"
  50. ;;
  51. esac
  52. echo -e "\n"
  53. if [ ! -d ~/miners/foxypool ]
  54. then
  55. mkdir ~/miners/foxypool
  56. fi
  57. echo -e "$(tput setaf 10)\nInstall Foxy-gh-Farmer:$(tput sgr0)"
  58. cd ~/miners/foxypool
  59. wget -q $URL
  60. unzip -q -o foxy-gh-farmer-ubuntu.zip
  61. rm foxy-gh-farmer-ubuntu.zip
  62. echo -e "\e[97mDone.\e[0m"
  63. function foxypool_service_ {
  64. echo -e "$(tput setaf 10)\nInstall FoxyPool service :$(tput sgr0)"
  65. cat > $HOME/foxypool.service << EOF
  66. [Unit]
  67. Description=Foxy-GH-Farmer Service
  68. After=network.target
  69. Wants=network-online.target
  70. [Service]
  71. Type=simple
  72. User=$USER
  73. WorkingDirectory=$HOME/miners/foxypool
  74. ExecStart=$HOME/miners/foxypool/foxy-gh-farmer -c $HOME/miners/foxypool/foxy-gh-farmer.yaml
  75. Restart=on-failure
  76. RestartSec=30
  77. LimitNOFILE=99999
  78. StandardOutput=syslog
  79. StandardError=syslog
  80. SyslogIdentifier=foxy-gh-farmer
  81. [Install]
  82. WantedBy=multi-user.target
  83. EOF
  84. sudo mv $HOME/foxypool.service /etc/systemd/system/foxypool.service >/dev/null
  85. sudo chmod 644 /etc/systemd/system/foxypool.service
  86. cat <<'EOF'>> foxypool.conf
  87. if $programname == 'foxy-gh-farmer' then /var/log/foxypool.log
  88. & stop
  89. EOF
  90. sudo cp foxypool.conf /etc/rsyslog.d/foxypool.conf
  91. sudo rm foxypool.conf
  92. if [ ! -f /var/log/foxypool.log ]
  93. then
  94. sudo touch /var/log/foxypool.log
  95. sudo chown syslog:adm /var/log/foxypool.log
  96. fi
  97. cat <<'EOF'>> logrot
  98. /var/log/foxypool.log {
  99. daily
  100. rotate 7
  101. copytruncate
  102. notifempty
  103. missingok
  104. su root syslog
  105. }
  106. EOF
  107. sudo cp logrot /etc/logrotate.d/foxypool
  108. sudo rm logrot
  109. sudo systemctl restart rsyslog >/dev/null 2>&1
  110. sudo systemctl daemon-reload >/dev/null 2>&1
  111. sudo systemctl enable foxypool >/dev/null 2>&1
  112. sudo systemctl start foxypool >/dev/null 2>&1
  113. echo -e "\e[97mDone.\e[0m\n"
  114. }
  115. function bashing {
  116. cat <<'EOF'>> ~/foxypool.sh
  117. #!/bin/bash
  118. CTR=xch19fewtlx936jx689nzf0ufngcunwvq7mjcdtncxtdqmh9axtpaelqx0k32s
  119. FPK=848417a79e0f94eafd158eac202b42c250caef8a4b262dbb1b5f6f7e347087f0e53e58a2e5585f85f67ac33507677176
  120. OUT=/Partage/Plots/
  121. ./cuda_plot_k32 -S 3 -g 0 -c $CTR -f $FPK -C 17 -n -1 -t /raid/ -3 /raid/ -d $OUT
  122. #ProofOfSpace farm -t 8 -d 100 -f /Partage/Plots/*.plot
  123. EOF
  124. chmod +x ~/foxypool.sh
  125. cp ~/foxypool.sh ~/chia/chia-gigahorse/cuda-plotter/linux/x86_64/foxypool.sh
  126. rm ~/foxypool.sh
  127. }
  128. if [ $FoxyPool_service = "YES" ]; then foxypool_service_;fi
  129. rm /tmp/latest
  130. bashing