foxy-pool.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. # The foxypool service (part of systemd)
  67. # file: /etc/systemd/system/foxypool.service
  68. [Unit]
  69. Description = Foxypool Service
  70. After=network.target
  71. [Service]
  72. Type=simple
  73. User = $USER
  74. WorkingDirectory= $HOME/miners/foxy-gh-farmer
  75. ExecStart = $HOME/miners/foxy-gh-farmer/foxy-gh-farmer -c $HOME/miners/foxy-gh-farmer/foxy-gh-farmer.yaml
  76. Restart = on-failure
  77. RestartSec=30
  78. LimitNOFILE=99999
  79. StandardOutput=syslog
  80. StandardError=syslog
  81. SyslogIdentifier=foxypool
  82. [Install]
  83. WantedBy = multi-user.target
  84. EOF
  85. sudo mv $HOME/foxypool.service /etc/systemd/system/foxypool.service >/dev/null
  86. sudo chmod 644 /etc/systemd/system/foxypool.service
  87. cat <<'EOF'>> foxypool.conf
  88. if $programname == 'flexfarmer' then /var/log/foxypool.log
  89. & stop
  90. EOF
  91. sudo cp foxypool.conf /etc/rsyslog.d/foxypool.conf
  92. sudo rm foxypool.conf
  93. if [ ! -f /var/log/foxypool.log ]
  94. then
  95. sudo touch /var/log/foxypool.log
  96. sudo chown syslog:adm /var/log/foxypool.log
  97. fi
  98. cat <<'EOF'>> logrot
  99. /var/log/foxypool.log {
  100. daily
  101. rotate 7
  102. copytruncate
  103. notifempty
  104. missingok
  105. su root syslog
  106. }
  107. EOF
  108. sudo cp logrot /etc/logrotate.d/foxypool
  109. sudo rm logrot
  110. sudo systemctl restart rsyslog >/dev/null 2>&1
  111. sudo systemctl daemon-reload >/dev/null 2>&1
  112. sudo systemctl enable foxypool >/dev/null 2>&1
  113. sudo systemctl start foxypool >/dev/null 2>&1
  114. echo -e "\e[97mDone.\e[0m"
  115. }
  116. function bashing {
  117. cat <<'EOF'>> ~/foxypool.sh
  118. CTR=xch1hsadv5h4c6mvk2av8vg6pdmezu8rapmrsta8z7ds0yd24yt2xshshqrtsy
  119. FPK=b6d0c62c90338b2dc9c5c2368e4acd1cbf60cadb3b86c0bf58a3706d59b276b49520bf8bfb4e07735fdfb92b03053170
  120. OUT=/Partage/Plots/
  121. ./cuda_plot_k32 -g 0 -c $CTR -f $FPK -C 17 -n 2 -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