setup.sh 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. #!/bin/bash
  2. set -e
  3. script_version="1.42"
  4. rdate="09/04/2018"
  5. #### OPTIONS ####
  6. ROCM_="NO" #rcom compute
  7. ETHMine="YES"
  8. SGMINER="YES"
  9. SGMINER_TT="YES"
  10. swap_size="16" # 0/4/8/16 Go
  11. #script_version=`grep version version.txt | awk '{ print $2 }'`
  12. #rdate=`grep release version.txt | awk '{ print $2 }'`
  13. if [ $UID -ne 0 ]
  14. then
  15. echo -e "\n\e[91mPlease run this script as ROOT : sudo ./setup.sh \e[0m"
  16. echo
  17. sleep 1
  18. exit
  19. fi
  20. echo ""
  21. echo -n -e " \e[97m\u2554"
  22. for i in {1..36}; do echo -e -n "\u2550"; done
  23. echo -e "\u2557\e[0m"
  24. echo -e " \e[97m\u2551 Mining Rig Auto-install \e[93m"V$script_version"\e[0m\e[97m \u2551\e[0m"
  25. echo -e " \e[97m\u2551 Release date: \e[93m"$rdate"\e[0m\e[97m \u2551\e[0m"
  26. echo -e " \e[97m\u2551 wareck@gmail.com \u2551\e[0m"
  27. echo -n -e " \e[97m\u255A"
  28. for j in {1..36}; do echo -e -n "\u2550";done
  29. echo -e -n "\u255D\e[0m"
  30. echo
  31. if [ $ROCM_ = "YES" ]; then echo -e "\e[91m AMD DRIVER + ROCm Compute firmware \e[0m\e[97m";fi
  32. if [ $ROCM_ = "NO" ]; then echo -e "\e[91m AMD GPU PRO Blockchain \e[0m\e[97m";fi
  33. if [ $ETHMine = "YES" ]; then echo -e "\e[97m +\e[91m Etherminer \e[0m\e[97m";fi
  34. if [ $SGMINER = "YES" ]; then echo -e "\e[97m +\e[91m Sgminer-nicehash\e[0m\e[97m";fi
  35. if [ $SGMINER_TT = "YES" ]; then echo -e "\e[97m +\e[91m Sgminer-timetravel\e[0m\e[97m";fi
  36. sleep 4
  37. sed -i -e "s/# set const/set const/g" /etc/nanorc
  38. echo -e "\n\e[95mExpand Disk :\e[0m"
  39. sudo growpart /dev/sda 1 |true
  40. sudo resize2fs /dev/sda1 |true
  41. echo -e "\e[97mDone !\e[0m"
  42. echo -e "\n\e[95mSystem Update :\e[0m"
  43. sudo apt-get update
  44. sudo add-apt-repository -y ppa:ethereum/ethereum -y
  45. sudo apt-get update
  46. sudo apt install ethereum git screen htop curl ntp pv git cmake libcryptopp-dev libleveldb-dev libjsoncpp-dev \
  47. build-essential libcurl4-gnutls-dev libboost-all-dev libgmp-dev \
  48. libreadline-dev libmicrohttpd-dev libjansson-dev libgmp-dev libssl-dev unzip python-nfqueue python-scapy -y
  49. cd ~
  50. sleep 5
  51. sudo sed -i -e "s/quiet splash/text/g" /etc/default/grub
  52. sudo sed -i -e 's#GRUB_CMDLINE_LINUX=""#GRUB_CMDLINE_LINUX="amddgpu.vm_fragment_size=9"#g' /etc/default/grub
  53. sudo update-grub2
  54. sudo apt dist-upgrade -y
  55. if [ $ROCM_ = "YES" ]
  56. then
  57. sudo apt-get install libnuma-dev -y
  58. echo -e "\n\e[95mInstall ROCm Compute:\e[0m"
  59. #update ROCM
  60. sudo apt-get install libnuma-dev -y
  61. wget -qO - http://repo.radeon.com/rocm/apt/debian/rocm.gpg.key | sudo apt-key add -
  62. sudo sh -c 'echo deb [arch=amd64] http://repo.radeon.com/rocm/apt/debian/ xenial main > /etc/apt/sources.list.d/rocm.list'
  63. sudo apt-get update
  64. sudo apt-get install rocm-dkms rocm-opencl-dev -y
  65. sudo usermod -a -G video work
  66. cd ..
  67. echo -e "\e[97mDone !\e[0m"
  68. fi
  69. echo -e "\n\e[95mInstall AMD Drivers :\e[0m"
  70. mkdir /home/work/tempo |true
  71. cd /home/work/tempo
  72. curl -f http://wareck.free.fr/grinder/drivers/AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2 | tar xvj
  73. #curl -sf http://wareck.free.fr/grinder/drivers/amdgpu-pro-17.40-492261.tar.xz | tar xvJ
  74. #cd amdgpu-pro-17.40-492261
  75. curl -sf http://wareck.free.fr/grinder/drivers/amdgpu-pro-17.50-511655.tar.xz | tar xvJ
  76. cd amdgpu-pro-17.50-511655
  77. if [ $ROCM_ = "YES" ]
  78. then
  79. sed -i -e "s/amdgpu-pro-dkms libdrm2-amdgpu-pro/libdrm2-amdgpu-pro/g" amdgpu-pro-install
  80. fi
  81. ./amdgpu-pro-install --pro --opencl=legacy,rocm -y
  82. echo -e "\n\e[95mInstall AMD SDK :\e[0m"
  83. cd /home/work/tempo
  84. ./AMD-APP-SDK-v3.0.130.136-GA-linux64.sh
  85. cd /opt/
  86. if [ -d ADL_SDK ]; then rm -r /opt/ADL_SDK; fi
  87. mkdir ADL_SDK
  88. cd ADL_SDK
  89. wget -c http://wareck.free.fr/grinder/drivers/ADL_SDK10.zip -O ADL_SDK.zip
  90. unzip -q ADL_SDK.zip
  91. cd ~
  92. echo -e "\e[97mDone !\e[0m"
  93. sleep 2
  94. echo -e "\n\e[95mInstall Claymore Miners :\e[0m"
  95. cd /home/work/
  96. sudo -u work curl -sf http://folivier.homelinux.org/genethos/miners/claymore_dual_11.6.tar.xz | tar xvJ
  97. echo ""
  98. sudo -u work curl -sf http://folivier.homelinux.org/genethos/miners/claymore_xmr_11.3.tar.xz | tar xvJ
  99. echo ""
  100. sudo -u work curl -sf http://folivier.homelinux.org/genethos/miners/claymore_zcash_12.6.tar.xz |tar xvJ
  101. echo ""
  102. sudo -u work curl -sf http://wareck.free.fr/grinder/miner.sh.tar.xz | tar xvJ
  103. sudo chown work claymore
  104. sudo chown work claymore_xmr
  105. sudo chown work claymore_zcash
  106. sudo chown work /home/work/miner.sh
  107. if [ $ETHMine = "YES" ]
  108. then
  109. echo -e "\n\e[95mInstall ETHMiner :\e[0m"
  110. cd ~
  111. if [ ! -d cpp_ethminer ]
  112. then
  113. git clone https://github.com/ethereum-mining/ethminer.git cpp_ethminer
  114. else
  115. cd cpp_ethminer
  116. git pull
  117. cd ~
  118. fi
  119. cd cpp_ethminer
  120. git submodule update --init --recursive
  121. mkdir build |true
  122. cd build
  123. cmake ..
  124. make
  125. cd ~
  126. ln -s cpp_ethminer/build/ethminer/ethminer ethminer | true
  127. fi
  128. echo -e "\e[97mDone !\e[0m"
  129. if [ $SGMINER = "YES" ]
  130. then
  131. echo -e "\n\e[95mInstall SGMINER:\e[0m"
  132. cd ~
  133. if [ ! -d sgminer ]
  134. then
  135. git clone https://github.com/nicehash/sgminer.git
  136. cd sgminer
  137. else
  138. cd sgminer
  139. git pull
  140. fi
  141. sudo apt install git autoconf automake libtool build-essential libncurses5-dev libcurl4-gnutls-dev -y
  142. git submodule init
  143. git submodule update
  144. autoreconf -fi
  145. CFLAGS="-Os -Wall -march=native -I/opt/AMDAPPSDK-3.0/include" LDFLAGS="-L/opt/amdgpu-pro/lib/x86_64-linux-gnu" ./configure --disable-git-version --disable-adl
  146. make -j2
  147. cd ~
  148. echo -e "\e[97mDone !\e[0m"
  149. fi
  150. if [ $SGMINER_TT = "YES" ]
  151. then
  152. echo -e "\n\e[95mInstall SGMINER-TIMETRAVEL:\e[0m"
  153. cd ~
  154. if [ ! -d sgminer-timetravel ]
  155. then
  156. sudo -u work curl -sf http://wareck.free.fr/openrig/miners/sgminer-timetravel.tar.xz | tar xvJ
  157. cd ~
  158. echo -e "\e[97mDone !\e[0m"
  159. fi
  160. fi
  161. echo -e "\n\e[95mDownloading NoFees Patch:\e[0m"
  162. cd ~
  163. if [ -d remove_miner_fees ]
  164. then
  165. cd remove_miner_fees
  166. git pull
  167. else
  168. git clone https://github.com/wareck/remove_miner_fees.git
  169. chown -R work remove_miner_fees
  170. fi
  171. chmod 777 /etc/rc.local
  172. if ! grep --quiet "/home/work/remove_miner_fees" /etc/rc.local
  173. then
  174. sed -i "s/exit 0//g" /etc/rc.local
  175. RC_LOCAL_CMD0="#python /home/work/remove_miner_fees/remove_mining_fees.py &"
  176. RC_LOCAL_CMD1="#python /home/work/remove_miner_fees/zcach.py &"
  177. RC_LOCAL_CMD2="#python /home/work/remove_miner_fees/hush.py &"
  178. RC_LOCAL_CMD3="#python /home/work/remove_miner_fees/ubiq.py &"
  179. RC_LOCAL_CMD4="#python /home/work/remove_miner_fees/soilcoin.py &"
  180. echo $RC_LOCAL_CMD0 >>/etc/rc.local
  181. echo $RC_LOCAL_CMD1 >>/etc/rc.local
  182. echo $RC_LOCAL_CMD2 >>/etc/rc.local
  183. echo $RC_LOCAL_CMD3 >>/etc/rc.local
  184. echo $RC_LOCAL_CMD4 >>/etc/rc.local
  185. echo "exit 0" >>/etc/rc.local
  186. fi
  187. echo -e "\e[97mDone !\e[0m"
  188. echo -e "\n\e[95mInstall AutoStart:\e[0m"
  189. if [ -f /home/work/.config/autostart/miner.sh.desktop ];then rm /home/work/.config/autostart/miner.sh.desktop |true ; fi
  190. if ! [ -d /home/work/.config ]; then mkdir /home/work/.config ;fi
  191. if ! [ -d /home/work/.config/autostart ]; then mkdir /home/work/.config/autostart;fi
  192. cat <<EOF>> /home/work/.config/autostart/miner.sh.desktop
  193. [Desktop Entry]
  194. Type=Application
  195. Exec=/home/work/miner.sh
  196. Hidden=false
  197. NoDisplay=false
  198. X-GNOME-Autostart-enabled=true
  199. Name[fr_FR]=miner
  200. Name=miner
  201. Comment[fr_FR]=miner
  202. Comment=miner
  203. EOF
  204. sleep 5
  205. chmod 777 /etc/rc.local
  206. if ! grep --quiet "su work -c '/home/work/miner.sh'" /etc/rc.local
  207. then
  208. sed -i "s/exit 0//g" /etc/rc.local
  209. RC_LOCAL_CMD0="su work -c '/home/work/miner.sh'"
  210. echo $RC_LOCAL_CMD0 >>/etc/rc.local
  211. echo "exit 0" >>/etc/rc.local
  212. fi
  213. echo -e "\e[97mDone !\e[0m"
  214. cd /home/work/
  215. sudo rm -r tempo | true
  216. echo -e "\n\e[95mMessage of the day mod :\e[0m"
  217. rm /etc/update-motd.d/00-header | true
  218. rm /etc/update-motd.d/10-help-text |true
  219. rm /etc/update-motd.d/90-updates-available |true
  220. rm /etc/update-motd.d/91-release-upgrade |true
  221. rm /etc/update-motd.d/98-fsck-at-reboot |true
  222. rm /etc/update-motd.d/98-reboot-required |true
  223. echo " - 00-header "
  224. cat <<EOF >> /etc/update-motd.d/00-header
  225. #!/bin/sh
  226. [ -r /etc/lsb-release ] && . /etc/lsb-release
  227. if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
  228. # Fall back to using the very slow lsb_release utility
  229. DISTRIB_DESCRIPTION=$(lsb_release -s -d)
  230. fi
  231. printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" " $(uname -o)" "$(uname -p)"
  232. EOF
  233. cd /etc/update-motd.d
  234. sudo -u work curl -sf http://folivier.homelinux.org/genethos/motd.tar.xz | tar xJ
  235. cd ~
  236. sed -i -e "s/#force_color_prompt=yes/force_color_prompt=yes/g" /home/work/.bashrc
  237. if ! grep --quiet "export DISPLAY=:0" /home/work/.bashrc
  238. then
  239. cat <<EOF>> /home/work/.bashrc
  240. export DISPLAY=:0
  241. echo -e "\e[93m
  242. _ _
  243. _| |_|___ ___ ___ ___
  244. | . | | . | . | -_| _|
  245. |___|_|_ |_ |___|_|
  246. |___|___| v$script_version
  247. \e[0m"
  248. EOF
  249. fi
  250. echo -e "\e[97mDone !\e[0m"
  251. echo -e "\n\e[95mBuilding Swapfile :\e[0m"
  252. if ! grep -q "swapfile" /etc/fstab ; then
  253. case $swap_size in
  254. 0) fst="0";;
  255. 4) sudo dd if=/dev/zero | pv -s 4G | dd of=/swapfile iflag=fullblock bs=1024 count=4194304;;
  256. 8) sudo dd if=/dev/zero | pv -s 8G | dd of=/swapfile iflag=fullblock bs=1024 count=8388608;;
  257. 16) sudo dd if=/dev/zero | pv -s 16G | dd of=/swapfile iflag=fullblock bs=1024 count=16777216 ;;
  258. *) echo -e "\e[91mError in configuration !\e[0m" && exit ;;
  259. esac
  260. sudo mkswap /swapfile
  261. sudo swapon /swapfile
  262. sudo cat <<'EOF'>> /etc/fstab
  263. /swapfile none swap sw 0 0
  264. EOF
  265. else
  266. echo -e "\e[93mSwapfile already enabled... \e[0m"
  267. echo -e "\e[93mCheck /etc/fsatb file.\e[0m\n"
  268. fi
  269. sudo chmod 600 /swapfile
  270. sudo touch /forcefsck
  271. echo -e "\e[97mDone !\e[0m"
  272. sudo usermod -a -G video work
  273. echo -e "\n\e[92mEverything was done...\e[0m"
  274. echo -e -n "Reboot in 15 seconds (CRTL+C to abord): "
  275. for i in {15..1}
  276. do
  277. echo -e -n "$i "
  278. sleep 1
  279. done
  280. reboot