setup_amd.sh 11 KB

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