install.sh 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #!/bin/bash
  2. set -e
  3. Version=1.0
  4. Release=27/Apr/2021
  5. author=wareck@gmail.com
  6. function Intro_(){
  7. echo -e "\e[38;5;154mDietpi Mine and Forget for Scrypt\e[0m"
  8. echo -e "\e[38;5;154mVersion: $Version Release:$Release\e[0m"
  9. echo -e "Author: wareck@gmail.com\n"
  10. if [ -f /boot/dietpi.txt ];then DietPi_="YES";else DietPi_="NO";fi
  11. if [ $DietPi_ = "YES" ]
  12. then
  13. echo -e "\e[97mImage detected : \e[38;5;154mDietpi\e[0m\n"
  14. #echo -e "This script will enable /etc/rc.local for AutoStart\n"
  15. else
  16. echo -e "\e[97mImage detected : \e[38;5;197mRaspberry Os\e[0m\n"
  17. fi
  18. sudo sed -i -e "s/# set const/set const/g" /etc/nanorc
  19. }
  20. function Update_(){
  21. echo -e "\e[95mLibraries Update:\e[0m"
  22. sudo apt-get update
  23. sudo apt-get upgrade -y
  24. sudo apt-get install git -y
  25. sudo apt-get install git build-essential autoconf automake libtool pkg-config \
  26. libjansson-dev uthash-dev libncursesw5-dev libudev-dev libusb-1.0-0-dev \
  27. libevent-dev libmicrohttpd-dev libhidapi-dev libgcrypt20-dev screen \
  28. libcurl4-openssl-dev libssl-dev -y
  29. }
  30. function Build_bfgminer(){
  31. echo -e "\n\e[95mBuild Bfgminer:\e[0m"
  32. cd /home/$USER
  33. if ! [ -d bfgminer ]
  34. then
  35. git clone https://github.com/wareck/bfgminer.git
  36. else
  37. cd /home/$USER/bfgminer
  38. git pull
  39. fi
  40. cd /home/$USER/bfgminer
  41. sudo usermod -a -G dialout,plugdev $USER
  42. CFLAGS="-O2 -march=native" ./autogen.sh
  43. ./configure --enable-scrypt --enable-futurebit
  44. make
  45. sudo cp 70-bfgminer.rules /etc/udev/rules.d/
  46. }
  47. function Build_cgminer_scrypt(){
  48. echo -e "\n\e[95mBuild Cgminer:\e[0m"
  49. cd /home/$USER
  50. if ! [ -d /home/$USER/cgminer-scrypt ]
  51. then
  52. git clone https://github.com/wareck/cgminer-lketc.git cgminer-scrypt
  53. else
  54. cd /home/$USER/cgminer-scrypt
  55. git pull
  56. fi
  57. cd /home/$USER/cgminer-scrypt
  58. sudo usermod -a -G dialout,plugdev $USER
  59. CFLAGS="-O2 -march=native" ./autogen.sh
  60. ./configure --enable-scrypt --enable-lketc --enable-zeus
  61. make
  62. sudo cp 01-cgminer.rules /etc/udev/rules.d/
  63. }
  64. function Build_cgminer_sha(){
  65. echo -e "\n\e[95mBuild Cgminer:\e[0m"
  66. cd /home/$USER
  67. if ! [ -d /home/$USER/cgminer ]
  68. then
  69. git clone https://github.com/wareck/cgminer-gekko.git cgminer-sha
  70. else
  71. cd /home/$USER/cgminer-sha
  72. git pull
  73. fi
  74. cd /home/$USER/cgminer-sha
  75. sudo usermod -a -G dialout,plugdev $USER
  76. CFLAGS="-O2 -march=native" ./autogen.sh
  77. ./configure --enable-gekko --enable-bflsc --enable-bitforce --enable-bitfury --enable-drillbit --enable-hashfast --enable-icarus --enable-klondike --enable-modminer
  78. make
  79. sudo cp 01-cgminer.rules /etc/udev/rules.d/
  80. }
  81. function Autostart_dietpi_ (){
  82. echo -e "\n\e[95mAdding rc.local Autostart:\e[0m"
  83. if ! [ -f /etc/rc.local ]
  84. then
  85. if [ -f /tmp/rc.local ];then rm /tmp/rc.local;fi
  86. cat <<'EOF'>>/tmp/rc.local
  87. #!/bin/bash
  88. exit 0
  89. EOF
  90. sudo cp /tmp/rc.local /etc/
  91. sudo chmod +x /etc/rc.local
  92. fi
  93. sudo systemctl disable rc-local
  94. sudo systemctl disable rc.local
  95. if ! [ -f /lib/systemd/system/rc-local.service ]
  96. then
  97. cat <<'EOF'>> /tmp/rc-local.service
  98. # This file is part of systemd.
  99. #
  100. # systemd is free software; you can redistribute it and/or modify it
  101. # under the terms of the GNU Lesser General Public License as published by
  102. # the Free Software Foundation; either version 2.1 of the License, or
  103. # (at your option) any later version.
  104. # This unit gets pulled automatically into multi-user.target by
  105. # systemd-rc-local-generator if /etc/rc.local is executable.
  106. [Unit]
  107. Description=/etc/rc.local Compatibility
  108. ConditionFileIsExecutable=/etc/rc.local
  109. After=network.target
  110. [Service]
  111. Type=forking
  112. ExecStart=/etc/rc.local start
  113. TimeoutSec=0
  114. RemainAfterExit=yes
  115. GuessMainPID=no
  116. EOF
  117. sudo cp /tmp/rc-local.service /lib/systemd/system/rc-local.service
  118. sudo systemctl daemon-reload
  119. fi
  120. echo -e "Done.\n"
  121. }
  122. function Minerconf_dietpi_ (){
  123. echo -e "\n\e[95mAdding Bfgminer to rc.local :\e[0m"
  124. if ! grep "#Start Mining" /etc/rc.local >/dev/null 2>&1
  125. then
  126. sudo bash -c 'sed -i -e "s/exit 0//g" /etc/rc.local'
  127. sudo bash -c 'echo "#Start Mining" >>/etc/rc.local'
  128. sudo bash -c 'echo "su - dietpi -c '\''screen -dmS miner /home/dietpi/bfgminer/bfgminer --scrypt -o stratum+tcp://litecoinpool.org:3333 -u wareck.1 -p 1,d=128 -S all --set MLD:clock=756 --set ZUS:clock=328 --set ZUS:chips=6'\''" >>/etc/rc.local'
  129. sudo bash -c 'echo "#su - dietpi -c '\''screen -dmS miner /home/dietpi/bfgminer/bfgminer --scrypt -o stratum+tcp://scrypt.eu.mine.zergpool.com:3433/#skipcbcheck#xnsub -u MJZqqHgsWeQGnh17e34qpPhJdJHM2afH6Q -p c=LTC,mc=DGB/MOON/XVG -S all --set MLD:clock=700 --set ZUS:clock=328 --set ZUS:chips=6'\''" >>/etc/rc.local'
  130. sudo bash -c 'echo "#su - dietpi -c '\''screen -dmS miner /home/dietpi/cgminer-sha/cgminer -o stratum+tcp://sha256.eu.mine.zergpool.com:3333#xnsub -u MJZqqHgsWeQGnh17e34qpPhJdJHM2afH6Q -p c=LTC,mc=BCA/BCHA/BSV/DGB/DVT/FCH/LANA/LCC/LCNT/LONG/PPC/PYRK/QBC/SHND/TIT/VLS --gekko-2pac-freq 100'\''" >>/etc/rc.local'
  131. sudo bash -c 'echo "#su - dietpi -c '\''screen -dmS miner /home/dietpi/cgminer-sha/cgminer -o stratum+tcp://eu.stratum.slushpool.com:3333 -u wareck.gekko -p x --gekko-2pac-freq 100'\''" >>/etc/rc.local'
  132. sudo bash -c 'echo "" >>/etc/rc.local'
  133. sudo bash -c 'echo "exit 0" >>/etc/rc.local'
  134. sudo chmod +x /etc/rc.local
  135. fi
  136. echo -e "Done."
  137. }
  138. function Minerconf_raspberryos_ (){
  139. echo -e "\n\e[95mAdding Bfgminer to rc.local :\e[0m"
  140. if ! grep "#Start Mining" /etc/rc.local >/dev/null 2>&1
  141. then
  142. sudo bash -c 'sed -i -e "s/exit 0//g" /etc/rc.local'
  143. sudo bash -c 'echo "#Start Mining" >>/etc/rc.local'
  144. sudo bash -c 'echo "su - pi -c '\''screen -dmS miner /home/pi/bfgminer/bfgminer --scrypt -o stratum+tcp://litecoinpool.org:3333 -u wareck.1 -p 1,d=128 -S all --set MLD:clock=756 --set ZUS:clock=328 --set ZUS:chips=6'\''" >>/etc/rc.local'
  145. sudo bash -c 'echo "#su - pi -c '\''screen -dmS miner /home/pi/bfgminer/bfgminer --scrypt -o stratum+tcp://scrypt.eu.mine.zergpool.com:3433/#skipcbcheck#xnsub -u MJZqqHgsWeQGnh17e34qpPhJdJHM2afH6Q -p c=LTC,mc=DGB/MOON/XVG -S all --set MLD:clock=700 --set ZUS:clock=328 --set ZUS:chips=6'\''" >>/etc/rc.local'
  146. sudo bash -c 'echo "#su - pi -c '\''screen -dmS miner /home/pi/cgminer-sha/cgminer -o stratum+tcp://sha256.eu.mine.zergpool.com:3333#xnsub -u MJZqqHgsWeQGnh17e34qpPhJdJHM2afH6Q -p c=LTC,mc=BCA/BCHA/BSV/DGB/DVT/FCH/LANA/LCC/LCNT/LONG/PPC/PYRK/QBC/SHND/TIT/VLS --gekko-2pac-freq 100'\''" >>/etc/rc.local'
  147. sudo bash -c 'echo "#su - pi -c '\''screen -dmS miner /home/pi/cgminer-sha/cgminer -o stratum+tcp://eu.stratum.slushpool.com:3333 -u wareck.gekko -p x --gekko-2pac-freq 100'\''" >>/etc/rc.local'
  148. sudo bash -c 'echo "" >>/etc/rc.local'
  149. sudo bash -c 'echo "exit 0" >>/etc/rc.local'
  150. sudo chmod +x /etc/rc.local
  151. fi
  152. echo -e "Done."
  153. }
  154. Intro_
  155. Update_
  156. Build_bfgminer
  157. Build_cgminer_sha
  158. Build_cgminer_scrypt
  159. if [ $DietPi_ = "YES" ]
  160. then
  161. Autostart_dietpi_
  162. Minerconf_dietpi_
  163. else
  164. Minerconf_raspberryos_
  165. fi
  166. echo -e "\nVoila ! reboot required"