setup_nvidia.sh 11 KB

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