setup.sh 9.7 KB

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