setup_amd.sh 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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. host_name="Miner1"
  9. ROCM_="NO" #rcom compute
  10. ETHMine="YES"
  11. XMRIG_AMD="YES"
  12. XMR_STAK="YES"
  13. SGMINER="YES"
  14. SGMINER_TT="YES"
  15. Lyra2z="YES"
  16. swap_size="0" # 0/4/8/16 Go
  17. #script_version=`grep version version.txt | awk '{ print $2 }'`
  18. #rdate=`grep release version.txt | awk '{ print $2 }'`
  19. if [ $UID -ne 0 ]
  20. then
  21. echo -e "\n\e[91mPlease run this script as ROOT : sudo ./setup.sh \e[0m"
  22. echo
  23. sleep 1
  24. exit
  25. fi
  26. claymore_dual_v="`curl -s $remote_folder/version.txt | awk 'NR==1 {print$3; exit}'`"
  27. claymore_zcash_v="`curl -s $remote_folder/version.txt | awk 'NR==2 {print$3; exit}'`"
  28. claymore_xmr_v="`curl -s $remote_folder/version.txt | awk 'NR==3 {print$3; exit}'`"
  29. echo ""
  30. echo -n -e " \e[97m\u2554"
  31. for i in {1..36}; do echo -e -n "\u2550"; done
  32. echo -e "\u2557\e[0m"
  33. echo -e " \e[97m\u2551 Mining Rig Auto-install \e[93m"V$script_version"\e[0m\e[97m \u2551\e[0m"
  34. echo -e " \e[97m\u2551 Release date: \e[93m"$rdate"\e[0m\e[97m \u2551\e[0m"
  35. echo -e " \e[97m\u2551 wareck@gmail.com \u2551\e[0m"
  36. echo -n -e " \e[97m\u255A"
  37. for j in {1..36}; do echo -e -n "\u2550";done
  38. echo -e -n "\u255D\e[0m"
  39. echo
  40. if [ $ROCM_ = "YES" ]; then echo -e "\e[91m AMD DRIVER + ROCm Compute firmware \e[0m\e[97m";fi
  41. if [ $ROCM_ = "NO" ]; then echo -e "\e[91m AMD GPU PRO Drivers $amd_driver_v\e[0m\e[97m";fi
  42. if [ $ETHMine = "YES" ]; then echo -e "\e[97m +\e[91m Etherminer \e[0m\e[97m";fi
  43. if [ $XMRIG_AMD = "YES" ]; then echo -e "\e[97m +\e[91m XMRig-amd \e[0m\e[97m";fi
  44. if [ $XMR_STAK = "YES" ]; then echo -e "\e[97m +\e[91m XMR-Stak \e[0m\e[97m";fi
  45. if [ $SGMINER = "YES" ]; then echo -e "\e[97m +\e[91m Sgminer-nicehash\e[0m\e[97m";fi
  46. if [ $SGMINER_TT = "YES" ]; then echo -e "\e[97m +\e[91m Sgminer-timetravel\e[0m\e[97m";fi
  47. echo -e "\e[97m +\e[91m Claymore dualminer $claymore_dual_v\e[0m\e[97m"
  48. echo -e "\e[97m +\e[91m Claymore zcash $claymore_zcash_v\e[0m\e[97m"
  49. echo -e "\e[97m +\e[91m Claymore xmr $claymore_xmr_v\e[0m\e[97m"
  50. if [ $Lyra2z = "YES" ]; then echo -e "\e[97m +\e[91m Lyra2z GPU Mining (experimental)\e[0m\e[97m";fi
  51. sleep 4
  52. sed -i -e "s/# set const/set const/g" /etc/nanorc
  53. echo -e "\n\e[95mExpand Disk :\e[0m"
  54. sudo growpart `df -h | grep /dev/sd | awk ' { print $1 }'| cut -c -8` 1 |true
  55. sudo resize2fs `df -h | grep /dev/sd | awk ' { print $1 }'` |true
  56. echo -e "\e[97mDone !\e[0m"
  57. echo -e "\n\e[95mSystem Update :\e[0m"
  58. sudo apt-get update
  59. sudo add-apt-repository -y ppa:ethereum/ethereum -y
  60. sudo apt-get update
  61. sudo apt install ethereum git screen htop curl ntp pv git cmake libcryptopp-dev libleveldb-dev libjsoncpp-dev \
  62. build-essential libcurl4-gnutls-dev libboost-all-dev libgmp-dev \
  63. libreadline-dev libmicrohttpd-dev libjansson-dev libgmp-dev libssl-dev unzip python-nfqueue python-scapy -y
  64. cd ~
  65. sleep 5
  66. sudo sed -i -e "s/quiet splash/text/g" /etc/default/grub
  67. sudo sed -i -e 's#GRUB_CMDLINE_LINUX=""#GRUB_CMDLINE_LINUX="amddgpu.vm_fragment_size=9"#g' /etc/default/grub
  68. sudo update-grub2
  69. sudo apt dist-upgrade -y
  70. if [ $ROCM_ = "YES" ]
  71. then
  72. sudo apt-get install libnuma-dev -y
  73. echo -e "\n\e[95mInstall ROCm Compute:\e[0m"
  74. #update ROCM
  75. sudo apt-get install libnuma-dev -y
  76. wget -qO - http://repo.radeon.com/rocm/apt/debian/rocm.gpg.key | sudo apt-key add -
  77. sudo sh -c 'echo deb [arch=amd64] http://repo.radeon.com/rocm/apt/debian/ xenial main > /etc/apt/sources.list.d/rocm.list'
  78. sudo apt-get update
  79. sudo apt-get install rocm-dkms rocm-opencl-dev -y
  80. sudo usermod -a -G video work
  81. cd ..
  82. echo -e "\e[97mDone !\e[0m"
  83. fi
  84. echo -e "\n\e[95mInstall AMD Drivers :\e[0m"
  85. mkdir /home/work/tempo |true
  86. cd /home/work/tempo
  87. curl -f http://wareck.free.fr/grinder/drivers/AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2 | tar xvj
  88. #curl -sf http://wareck.free.fr/grinder/drivers/amdgpu-pro-17.50-511655.tar.xz | tar xvJ
  89. wget -c http://wareck.free.fr/grinder/drivers/amdgpu-pro-18.20-606296.tar.xz
  90. tar xvfJ amdgpu-pro-18.20-606296.tar.xz
  91. rm amdgpu-pro-18.20-606296.tar.xz
  92. #cd amdgpu-pro-17.50-511655
  93. cd amdgpu-pro-18.20-606296
  94. if [ $ROCM_ = "YES" ]
  95. then
  96. sed -i -e "s/amdgpu-pro-dkms libdrm2-amdgpu-pro/libdrm2-amdgpu-pro/g" amdgpu-pro-install
  97. ./amdgpu-pro-install --pro --opencl=legacy,rocm -y
  98. else
  99. ./amdgpu-pro-install --pro --opencl=legacy -y
  100. fi
  101. echo -e "\n\e[95mInstall AMD SDK :\e[0m"
  102. cd /home/work/tempo
  103. ./AMD-APP-SDK-v3.0.130.136-GA-linux64.sh
  104. cd /opt/
  105. if [ -d ADL_SDK ]; then rm -r /opt/ADL_SDK; fi
  106. mkdir ADL_SDK
  107. cd ADL_SDK
  108. wget -c http://wareck.free.fr/grinder/drivers/ADL_SDK10.zip -O ADL_SDK.zip
  109. unzip -q ADL_SDK.zip
  110. cd ~
  111. echo -e "\e[97mDone !\e[0m"
  112. sleep 2
  113. echo -e "\n\e[95mInstall Claymore Miners :\e[0m"
  114. cd /home/work/
  115. sudo -u work curl -sf $remote_folder/miners/claymore_dual_$claymore_dual_v.tar.xz | tar xvJ
  116. echo ""
  117. sudo -u work curl -sf $remote_folder/miners/claymore_zcash_$claymore_zcash_v.tar.xz | tar xvJ
  118. echo ""
  119. sudo -u work curl -sf $remote_folder/miners/claymore_xmr_$claymore_xmr_v.tar.xz | tar xvJ
  120. echo ""
  121. sudo -u work curl -sf http://wareck.free.fr/grinder/miner.sh.tar.xz | tar xvJ
  122. sudo chown work claymore
  123. sudo chown work claymore_xmr
  124. sudo chown work claymore_zcash
  125. sudo chown work /home/work/miner.sh
  126. if [ $ETHMine = "YES" ]
  127. then
  128. echo -e "\n\e[95mInstall ETHMiner :\e[0m"
  129. cd ~
  130. if [ ! -d cpp_ethminer ]
  131. then
  132. git clone https://github.com/ethereum-mining/ethminer.git cpp_ethminer
  133. else
  134. cd cpp_ethminer
  135. git pull
  136. cd ~
  137. fi
  138. cd cpp_ethminer
  139. git submodule update --init --recursive
  140. mkdir build |true
  141. cd build
  142. cmake .. -DETHASHCUDA=OFF -DETHASHCL=ON
  143. make
  144. cd ~
  145. ln -s cpp_ethminer/build/ethminer/ethminer ethminer | true
  146. fi
  147. echo -e "\e[97mDone !\e[0m"
  148. if [ $SGMINER = "YES" ]
  149. then
  150. echo -e "\n\e[95mInstall SGMINER-Nicehash:\e[0m"
  151. cd ~
  152. if [ ! -d sgminer ]
  153. then
  154. git clone https://github.com/nicehash/sgminer.git
  155. cd sgminer
  156. else
  157. cd sgminer
  158. git pull
  159. fi
  160. sudo apt install git autoconf automake libtool build-essential libncurses5-dev libcurl4-gnutls-dev -y
  161. git submodule init
  162. git submodule update
  163. autoreconf -fi
  164. 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
  165. make $(if $(THREADS="-j$(($(tail -c 2 /sys/devices/system/node/node0/cpulist 2>/dev/null)+2))"); then echo $THREADS; fi)
  166. cd ~
  167. echo -e "\e[97mDone !\e[0m"
  168. fi
  169. if [ $SGMINER_TT = "YES" ]
  170. then
  171. echo -e "\n\e[95mInstall SGMINER-TIMETRAVEL:\e[0m"
  172. cd ~
  173. if [ ! -d sgminer-timetravel ]
  174. then
  175. sudo -u work curl -sf http://wareck.free.fr/openrig/miners/sgminer-timetravel.tar.xz | tar xvJ
  176. cd ~
  177. echo -e "\e[97mDone !\e[0m"
  178. fi
  179. fi
  180. if [ $Lyra2z = "YES" ]
  181. then
  182. echo -e "\n\e[95mInstall Lyra2Z GPU Miner (experimental):\e[0m"
  183. cd ~
  184. git clone https://github.com/wareck/sgminer-lyra2z.git
  185. cd ~/sgminer-lyra2z
  186. git pull
  187. git submodule init
  188. git submodule update
  189. ./autogen.sh
  190. 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
  191. make $(if $(THREADS="-j$(($(tail -c 2 /sys/devices/system/node/node0/cpulist 2>/dev/null)+2))"); then echo $THREADS; fi)
  192. cd ~
  193. echo "Done."
  194. fi
  195. if [ $XMRIG_AMD = "YES" ]
  196. then
  197. echo -e "\n\e[95mInstall XMRIG-AMD:\e[0m"
  198. cd ~
  199. git clone https://github.com/xmrig/xmrig-amd.git
  200. cd /tmp/
  201. if ! [ -d libuv ]; then git clone https://github.com/libuv/libuv.git ;fi
  202. cd libuv
  203. ./autogen.sh
  204. ./configure
  205. make -j $(nproc)
  206. sudo make install
  207. sudo ldconfig
  208. cd ~
  209. cd xmrig-amd
  210. if ! [ -f patch_donate.patch ]
  211. then
  212. cat <<'EOF'>> patch_donate.patch
  213. diff --git a/src/donate.h b/src/donate.h
  214. index 46f26b7..67a9cb0 100644
  215. --- a/src/donate.h
  216. +++ b/src/donate.h
  217. @@ -43,8 +43,8 @@
  218. * XMR: 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8n$
  219. * BTC: 1P7ujsXeX7GxQwHNnJsRMgAdNkFZmNVqJT
  220. */
  221. -constexpr const int kDefaultDonateLevel = 5;
  222. -constexpr const int kMinimumDonateLevel = 1;
  223. +constexpr const int kDefaultDonateLevel = 0;
  224. +constexpr const int kMinimumDonateLevel = 0;
  225. #endif /* __DONATE_H__ */
  226. EOF
  227. patch -p1 <patch_donate.patch
  228. fi
  229. if ! [ -d build ];then mkdir build; fi
  230. cd build
  231. cmake ..
  232. make
  233. cd ~
  234. if ! [ -f xmrig ]; then ln -s xmrig-amd/build/xmrig-amd xmrig;fi
  235. echo "Done."
  236. fi
  237. if [ $XMR_STAK = "YES" ]
  238. then
  239. echo -e "\n\e[95mInstall XMR-STAK:\e[0m"
  240. cd ~
  241. git clone https://github.com/fireice-uk/xmr-stak.git xmr_stak
  242. cd /tmp/
  243. cat <<'EOF'>> patch_donate.patch
  244. diff --git a/xmrstak/donate-level.hpp b/xmrstak/donate-level.hpp
  245. index 71b7962..53980d4 100644
  246. --- a/xmrstak/donate-level.hpp
  247. +++ b/xmrstak/donate-level.hpp
  248. @@ -15,4 +15,4 @@
  249. *
  250. */
  251. -constexpr double fDevDonationLevel = 2.0 / 100.0;
  252. +constexpr double fDevDonationLevel = 0.0 / 100.0;
  253. EOF
  254. cd ~
  255. cd xmr_stak
  256. sudo mv /tmp/patch_donate.patch .
  257. patch -p1 < patch_donate.patch
  258. sudo ln -s /opt/amdgpu-pro/lib/x86_64-linux-gnu/libOpenCL.so /usr/lib/libOpenCL.so.1 | true
  259. mkdir build
  260. cd build
  261. cmake .. -DCPU_ENABLE=OFF -DHWLOC_ENABLE=OFF -DMICROHTTPD_ENABLE=OFF -DCMAKE_LINK_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DCUDA_ENABLE=OFF \
  262. -DOpenCL_LIBRARY=/opt/AMDAPPSDK-3.0/lib/x86_64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/opt/AMDAPPSDK-3.0/include/
  263. make -j2
  264. cd ~
  265. ln -s xmr_stak/build/bin/xmr-stak xmr-stak
  266. sudo cp xmr_stak/build/bin/libxmrstak_opencl_backend.so /lib/
  267. cd ~
  268. echo "Done"
  269. fi
  270. echo -e "\n\e[95mDownloading NoFees Patch:\e[0m"
  271. cd ~
  272. if [ -d remove_miner_fees ]
  273. then
  274. cd remove_miner_fees
  275. git pull
  276. else
  277. git clone https://github.com/wareck/remove_miner_fees.git
  278. chown -R work remove_miner_fees
  279. fi
  280. chmod 777 /etc/rc.local
  281. if ! grep --quiet "/home/work/remove_miner_fees" /etc/rc.local
  282. then
  283. sed -i "s/exit 0//g" /etc/rc.local
  284. RC_LOCAL_CMD0="#python /home/work/remove_miner_fees/remove_mining_fees.py &"
  285. RC_LOCAL_CMD1="#python /home/work/remove_miner_fees/zcach.py &"
  286. RC_LOCAL_CMD2="#python /home/work/remove_miner_fees/hush.py &"
  287. RC_LOCAL_CMD3="#python /home/work/remove_miner_fees/ubiq.py &"
  288. RC_LOCAL_CMD4="#python /home/work/remove_miner_fees/soilcoin.py &"
  289. echo $RC_LOCAL_CMD0 >>/etc/rc.local
  290. echo $RC_LOCAL_CMD1 >>/etc/rc.local
  291. echo $RC_LOCAL_CMD2 >>/etc/rc.local
  292. echo $RC_LOCAL_CMD3 >>/etc/rc.local
  293. echo $RC_LOCAL_CMD4 >>/etc/rc.local
  294. echo "exit 0" >>/etc/rc.local
  295. fi
  296. echo -e "\e[97mDone !\e[0m"
  297. echo -e "\n\e[95mInstall AutoStart:\e[0m"
  298. if [ -f /home/work/.config/autostart/miner.sh.desktop ];then rm /home/work/.config/autostart/miner.sh.desktop |true ; fi
  299. if ! [ -d /home/work/.config ]; then mkdir /home/work/.config ;fi
  300. if ! [ -d /home/work/.config/autostart ]; then mkdir /home/work/.config/autostart;fi
  301. cat <<EOF>> /home/work/.config/autostart/miner.sh.desktop
  302. [Desktop Entry]
  303. Type=Application
  304. Exec=/home/work/miner.sh
  305. Hidden=false
  306. NoDisplay=false
  307. X-GNOME-Autostart-enabled=true
  308. Name[fr_FR]=miner
  309. Name=miner
  310. Comment[fr_FR]=miner
  311. Comment=miner
  312. EOF
  313. sleep 5
  314. chmod 777 /etc/rc.local
  315. if ! grep --quiet "su work -c '/home/work/miner.sh'" /etc/rc.local
  316. then
  317. sed -i "s/exit 0//g" /etc/rc.local
  318. RC_LOCAL_CMD0="su work -c '/home/work/miner.sh'"
  319. echo $RC_LOCAL_CMD0 >>/etc/rc.local
  320. echo "exit 0" >>/etc/rc.local
  321. fi
  322. echo -e "\e[97mDone !\e[0m"
  323. cd /home/work/
  324. sudo rm -r tempo | true
  325. echo -e "\n\e[95mMessage of the day mod :\e[0m"
  326. rm /etc/update-motd.d/00-header | true
  327. rm /etc/update-motd.d/10-help-text |true
  328. rm /etc/update-motd.d/90-updates-available |true
  329. rm /etc/update-motd.d/91-release-upgrade |true
  330. rm /etc/update-motd.d/98-fsck-at-reboot |true
  331. rm /etc/update-motd.d/98-reboot-required |true
  332. echo " - 00-header "
  333. cat <<EOF >> /etc/update-motd.d/00-header
  334. #!/bin/sh
  335. [ -r /etc/lsb-release ] && . /etc/lsb-release
  336. if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
  337. # Fall back to using the very slow lsb_release utility
  338. DISTRIB_DESCRIPTION=$(lsb_release -s -d)
  339. fi
  340. printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" " $(uname -o)" "$(uname -p)"
  341. EOF
  342. cd /etc/update-motd.d
  343. sudo -u work curl -sf http://folivier.homelinux.org/genethos/motd.tar.xz | tar xJ
  344. cd ~
  345. sed -i -e "s/#force_color_prompt=yes/force_color_prompt=yes/g" /home/work/.bashrc
  346. if ! grep --quiet "export DISPLAY=:0" /home/work/.bashrc
  347. then
  348. cat <<EOF>> /home/work/.bashrc
  349. export DISPLAY=:0
  350. echo -e "\e[93m
  351. _____ _____ _____
  352. | | | | | _ |
  353. | | |_| | | |_| __|
  354. |_____|_|_|_|_|_|__|
  355. Open Mining Platform
  356. v$script_version
  357. \e[0m"
  358. EOF
  359. fi
  360. echo -e "\e[97mDone !\e[0m"
  361. echo -e "\n\e[95mBuilding Swapfile :\e[0m"
  362. if ! grep -q "swapfile" /etc/fstab ; then
  363. case $swap_size in
  364. 0) fst="0";;
  365. 4) sudo dd if=/dev/zero | pv -s 4G | dd of=/swapfile iflag=fullblock bs=1024 count=4194304;;
  366. 8) sudo dd if=/dev/zero | pv -s 8G | dd of=/swapfile iflag=fullblock bs=1024 count=8388608;;
  367. 16) sudo dd if=/dev/zero | pv -s 16G | dd of=/swapfile iflag=fullblock bs=1024 count=16777216 ;;
  368. *) echo -e "\e[91mError in configuration !\e[0m" && exit ;;
  369. esac
  370. if ! [ $swap_size = "0" ]
  371. then
  372. sudo mkswap /swapfile
  373. sudo swapon /swapfile
  374. sudo cat <<'EOF'>> /etc/fstab
  375. /swapfile none swap sw 0 0
  376. EOF
  377. sudo chmod 600 /swapfile
  378. sudo touch /forcefsck
  379. fi
  380. else
  381. echo -e "\e[93mSwapfile already enabled... \e[0m"
  382. echo -e "\e[93mCheck /etc/fsatb file.\e[0m\n"
  383. fi
  384. echo -e "\e[97mDone !\e[0m"
  385. sudo usermod -a -G video work
  386. echo -e "\n\e[95mConfigure Hostname and Rig name:\e[0m"
  387. touch /tmp/hostname
  388. echo $host_name >/tmp/hostname
  389. sudo bash -c 'cp /tmp/hostname /etc/hostname'
  390. sed -i -e "s/digger/$host_name/g" /etc/hosts
  391. # rename rig in miner.sh
  392. sed -i -e "s/OpenRig/$host_name/g" miner.sh
  393. # nano count lines
  394. sed -i -e "s/# set const/set const/g" /etc/nanorc
  395. # reset ssh keys
  396. rm /etc/ssh/ssh_host_*
  397. dpkg-reconfigure openssh-server
  398. echo "Done"
  399. echo -e "\n\e[92mEverything was done...\e[0m"
  400. echo -e -n "Reboot in 15 seconds (CRTL+C to abord): "
  401. for i in {15..1}
  402. do
  403. echo -e -n "$i "
  404. sleep 1
  405. done
  406. reboot