setup_amd.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. #!/bin/bash
  2. set -e
  3. script_version="1.54"
  4. rdate="20/02/2019"
  5. remote_folder="http://wareck.free.fr/openrig"
  6. lsb_v="`lsb_release -r | awk '{print$2; exit}'`"
  7. lsb_r="`lsb_release -d | awk '{print$2" "$3}'`"
  8. curdir=$PWD
  9. #### OPTIONS ####
  10. host_name="OpenRig"
  11. Drivers="16.40"
  12. #Drivers="17.50"
  13. #Drivers="18.20"
  14. #Drivers="18.40"
  15. #Drivers="18.50" #ubuntu 18.04
  16. #Drivers="19.30" #ubuntu 18.04
  17. ROCM_="NO" #rcom compute
  18. ETHMine="YES"
  19. XMRIG_AMD="YES"
  20. XMR_STAK="YES"
  21. SGMINER="YES"
  22. SGMINER_TT="YES"
  23. SGMINER_x16r="YES"
  24. Lyra2z="NO"
  25. Phoenix="YES"
  26. lolMiner="YES"
  27. Gminer="YES"
  28. swap_size="16" # 0/4/8/16 Go
  29. NewNiceHash="YES"
  30. Pro="YES"
  31. #script_version=`grep version version.txt | awk '{ print $2 }'`
  32. #rdate=`grep release version.txt | awk '{ print $2 }'`
  33. #if [[ $lsb_v = "18.04" || $lsb_v = "18.10" ]]; then Drivers="18.50" && Lyra2z="NO" && ROCM_="NO" ;fi
  34. if [ $Drivers = "16.40" ]; then amd_driver_v="16.40-348864" && ROCM_="NO" ;fi
  35. if [ $Drivers = "17.50" ]; then amd_driver_v="17.50-511655" && ROCM_="NO" ;fi
  36. if [ $Drivers = "18.20" ]; then amd_driver_v="18.20-606296" && Lyra2z="NO" && ROCM_="NO" ;fi
  37. if [ $Drivers = "18.40" ]; then amd_driver_v="18.40-673869" && Lyra2z="NO" && ROCM_="NO" ;fi
  38. if [ $Drivers = "18.50" ]; then amd_driver_v="18.50-708488" && Lyra2z="NO" && ROCM_="NO" ;fi
  39. if [ $Drivers = "19.30" ]; then amd_driver_v="19.30-855429" && Lyra2z="NO" && ROCM_="NO" ;fi
  40. if [ $UID -ne 0 ]
  41. then
  42. echo -e "\n\e[91mPlease run this script as ROOT : sudo ./setup.sh \e[0m"
  43. echo
  44. sleep 1
  45. exit
  46. fi
  47. claymore_dual_v="`curl -s $remote_folder/version.txt | awk 'NR==1 {print$3; exit}'`"
  48. claymore_zcash_v="`curl -s $remote_folder/version.txt | awk 'NR==2 {print$3; exit}'`"
  49. claymore_xmr_v="`curl -s $remote_folder/version.txt | awk 'NR==3 {print$3; exit}'`"
  50. lolminer_v="`curl -s $remote_folder/version.txt | awk 'NR==6 {print$3; exit}'`"
  51. Phoenix_v="`curl -s $remote_folder/version.txt | awk 'NR==7 {print$3; exit}'`"
  52. Gminer_v="`curl -s $remote_folder/version.txt | awk 'NR==8 {print$3; exit}'`"
  53. echo ""
  54. echo -n -e " \e[97m\u2554"
  55. for i in {1..36}; do echo -e -n "\u2550"; done
  56. echo -e "\u2557\e[0m"
  57. echo -e " \e[97m\u2551 Mining Rig Auto-install \e[93m"V$script_version"\e[0m\e[97m \u2551\e[0m"
  58. echo -e " \e[97m\u2551 Release date: \e[93m"$rdate"\e[0m\e[97m \u2551\e[0m"
  59. echo -e " \e[97m\u2551 wareck@gmail.com \u2551\e[0m"
  60. echo -n -e " \e[97m\u255A"
  61. for j in {1..36}; do echo -e -n "\u2550";done
  62. echo -e -n "\u255D\e[0m"
  63. echo
  64. echo
  65. if [ $lsb_v = "18.04" ]; then echo -e "\e[97m Ubuntu 18.04 \e[0m\e[97m";fi
  66. if [ $lsb_v = "18.10" ]; then echo -e "\e[97m Ubuntu 18.10 \e[0m\e[97m";fi
  67. if [ $ROCM_ = "YES" ]; then echo -e "\e[94m AMD DRIVER + ROCm Compute firmware \e[0m\e[97m";fi
  68. if [ $ROCM_ = "NO" ]; then echo -e "\e[94m AMD GPU PRO Drivers $amd_driver_v\e[0m\e[97m";fi
  69. echo -e ""
  70. if [ $NewNiceHash = "YES" ]; then echo -e "\e[97m +\e[92m New NicheHash\e[0m\e[93m";fi
  71. if [ $ETHMine = "YES" ]; then echo -e "\e[97m +\e[91m Etherminer \e[0m\e[97m";fi
  72. if [ $XMRIG_AMD = "YES" ]; then echo -e "\e[97m +\e[91m XMRig-amd \e[0m\e[97m";fi
  73. if [ $XMR_STAK = "YES" ]; then echo -e "\e[97m +\e[91m XMR-Stak \e[0m\e[97m";fi
  74. if [ $lolMiner = "YES" ]; then echo -e "\e[97m +\e[91m lolMiner v$lolminer_v\e[0m\e[97m";fi
  75. if [ $SGMINER = "YES" ]; then echo -e "\e[97m +\e[91m Sgminer-nicehash\e[0m\e[97m";fi
  76. if [ $SGMINER_TT = "YES" ]; then echo -e "\e[97m +\e[91m Sgminer-timetravel\e[0m\e[97m";fi
  77. if [ $SGMINER_x16r = "YES" ]; then echo -e "\e[97m +\e[91m Sgminer-x16r\e[0m\e[97m";fi
  78. echo -e "\e[97m +\e[91m Claymore dualminer $claymore_dual_v\e[0m\e[97m"
  79. echo -e "\e[97m +\e[91m Claymore zcash $claymore_zcash_v\e[0m\e[97m"
  80. echo -e "\e[97m +\e[91m Claymore xmr $claymore_xmr_v\e[0m\e[97m"
  81. if [ $Lyra2z = "YES" ]; then echo -e "\e[97m +\e[91m Lyra2z GPU Mining (experimental)\e[0m\e[97m";fi
  82. if [ $Phoenix = "YES" ]; then echo -e "\e[97m +\e[91m Phoenix ETH v$Phoenix_v \e[0m\e[97m";fi
  83. if [ $Gminer = "YES" ]; then echo -e "\e[97m +\e[91m Gminer v$Gminer_v \e[0m\e[97m";fi
  84. echo
  85. sleep 4
  86. sed -i -e "s/# set const/set const/g" /etc/nanorc
  87. echo -e "\n\e[95mExpand Disk :\e[0m"
  88. sudo growpart `df -h | grep /dev/sd | awk ' { print $1 }'| cut -c -8` 1 |true
  89. sudo resize2fs `df -h | grep /dev/sd | awk ' { print $1 }'` |true
  90. echo -e "\e[97mDone !\e[0m"
  91. echo -e "\n\e[95mSystem Update :\e[0m"
  92. sudo apt-get update && echo ""
  93. sudo add-apt-repository -y ppa:ethereum/ethereum -y && echo ""
  94. sudo apt-get update && echo ""
  95. cd ~
  96. sudo sed -i -e "s/quiet splash/text/g" /etc/default/grub
  97. sudo sed -i -e 's#GRUB_CMDLINE_LINUX=""#GRUB_CMDLINE_LINUX="amddgpu.vm_fragment_size=9"#g' /etc/default/grub
  98. sudo update-grub2 && echo ""
  99. sudo apt dist-upgrade -y && echo ""
  100. if ! [[ $lsb_v = "18.04" || $lsb_v = "18.10" ]];then sudo apt-get remove linux-image-4.4.0-116* linux-headers-4.4.0-116* -y ;fi
  101. sudo apt install ethereum git screen htop curl ntp pv git cmake libleveldb-dev libjsoncpp-dev \
  102. build-essential libcurl4-gnutls-dev libboost-all-dev libgmp-dev \
  103. libreadline-dev libmicrohttpd-dev libjansson-dev libgmp-dev libssl-dev unzip python-nfqueue python-scapy mesa-common-dev -y && echo ""
  104. if ! [[ $lsb_v = "18.04" || $lsb_v = "18.10" ]];then sudo apt install libcryptopp-dev -y ;fi && echo""
  105. if ! [[ $lsb_v = "18.04" || $lsb_v = "18.10" ]];then sudo apt-get install --install-recommends xserver-xorg-hwe-16.04 -y; fi && echo ""
  106. if [ $ROCM_ = "YES" ]
  107. then
  108. sudo apt-get install libnuma-dev -y
  109. echo -e "\n\e[95mInstall ROCm Compute:\e[0m"
  110. #update ROCM
  111. sudo apt-get install libnuma-dev -y
  112. wget -qO - http://repo.radeon.com/rocm/apt/debian/rocm.gpg.key | sudo apt-key add -
  113. sudo sh -c 'echo deb [arch=amd64] http://repo.radeon.com/rocm/apt/debian/ xenial main > /etc/apt/sources.list.d/rocm.list'
  114. sudo apt-get update
  115. sudo apt-get install rocm-opencl-dev -y
  116. sudo usermod -a -G video work
  117. cd ..
  118. echo -e "\e[97mDone !\e[0m"
  119. fi
  120. echo -e "\n\e[95mInstall AMD Drivers :\e[0m"
  121. if ! [ -d /home/work/tempo ];then mkdir /home/work/tempo ; fi
  122. cd /home/work/tempo
  123. if [ $Drivers = "16.40" ]
  124. then
  125. wget -c http://wareck.free.fr/grinder/drivers/amdgpu-pro-16.40-348864.tar.xz
  126. tar xvfJ amdgpu-pro-16.40-348864.tar.xz
  127. rm amdgpu-pro-16.40-348864.tar.xz
  128. cd amdgpu-pro-16.40-348864
  129. if [ $ROCM_ = "YES" ]
  130. then
  131. sed -i -e "s/amdgpu-pro-dkms libdrm2-amdgpu-pro/libdrm2-amdgpu-pro/g" amdgpu-pro-install
  132. ./amdgpu-pro-install --px -y
  133. else
  134. ./amdgpu-pro-install --px -y
  135. fi
  136. fi
  137. if [ $Drivers = "17.50" ]
  138. then
  139. wget -c http://wareck.free.fr/grinder/drivers/amdgpu-pro-17.50-511655.tar.xz
  140. tar xvfJ amdgpu-pro-17.50-511655.tar.xz
  141. rm amdgpu-pro-17.50-511655.tar.xz
  142. cd amdgpu-pro-17.50-511655
  143. if [ $ROCM_ = "YES" ]
  144. then
  145. sed -i -e "s/amdgpu-pro-dkms libdrm2-amdgpu-pro/libdrm2-amdgpu-pro/g" amdgpu-pro-install
  146. ./amdgpu-pro-install --pro --opencl=legacy,rocm -y
  147. else
  148. if [ $Pro = "YES" ]
  149. then
  150. ./amdgpu-pro-install --pro --opencl=legacy -y
  151. else
  152. ./amdgpu-install --opencl=legacy -y
  153. fi
  154. fi
  155. fi
  156. if [ $Drivers = "18.20" ]
  157. then
  158. echo "Download amdgpu-pro-18.20-606296.tar.xz"
  159. wget -c http://wareck.free.fr/grinder/drivers/amdgpu-pro-18.20-606296.tar.xz
  160. tar xvfJ amdgpu-pro-18.20-606296.tar.xz
  161. rm amdgpu-pro-18.20-606296.tar.xz
  162. cd amdgpu-pro-18.20-606296
  163. if [ $ROCM_ = "YES" ]
  164. then
  165. sed -i -e "s/amdgpu-pro-dkms libdrm2-amdgpu-pro/libdrm2-amdgpu-pro/g" amdgpu-pro-install
  166. ./amdgpu-pro-install --pro --opencl=legacy,rocm -y
  167. else
  168. if [ $Pro = "YES" ]
  169. then
  170. ./amdgpu-pro-install --pro --opencl=legacy -y
  171. else
  172. ./amdgpu-install --opencl=legacy -y
  173. fi
  174. fi
  175. fi
  176. if [ $Drivers = "18.40" ]
  177. then
  178. echo "Download amdgpu-pro-18.40-673869-ubuntu-16.04.tar.xz"
  179. wget -c http://wareck.free.fr/grinder/drivers/amdgpu-pro-18.40-673869-ubuntu-16.04.tar.xz
  180. tar xvfJ amdgpu-pro-18.40-673869-ubuntu-16.04.tar.xz
  181. rm amdgpu-pro-18.40-673869-ubuntu-16.04.tar.xz
  182. cd amdgpu-pro-18.40-673869-ubuntu-16.04
  183. ./amdgpu-pro-install --pro --opencl=legacy -y
  184. fi
  185. if [ $Drivers = "18.50" ]
  186. then
  187. echo "Download amdgpu-pro-18.40-673869-ubuntu-16.04.tar.xz"
  188. wget -c http://wareck.free.fr/grinder/drivers/amdgpu-pro-18.50-708488-ubuntu-18.04.tar.xz
  189. tar xvfJ amdgpu-pro-18.50-708488-ubuntu-18.04.tar.xz
  190. rm amdgpu-pro-18.50-708488-ubuntu-18.04.tar.xz
  191. cd amdgpu-pro-18.50-708488-ubuntu-18.04
  192. ./amdgpu-pro-install --pro --opencl=legacy -y
  193. fi
  194. if [ $Drivers = "19.30" ]
  195. then
  196. echo "Download amdgpu-pro-19.30-855429-ubuntu-18.04.tar.xz"
  197. wget -c http://wareck.free.fr/grinder/drivers/amdgpu-pro-19.30-855429-ubuntu-18.04.tar.xz
  198. tar xvfJ amdgpu-pro-19.30-855429-ubuntu-18.04.tar.xz
  199. rm amdgpu-pro-19.30-855429-ubuntu-18.04.tar.xz
  200. cd amdgpu-pro-19.30-855429-ubuntu-18.04
  201. ./amdgpu-pro-install --pro --opencl=legacy -y
  202. fi
  203. echo -e "\n\e[95mInstall AMD SDK :\e[0m"
  204. cd /home/work/tempo/
  205. curl -f http://wareck.free.fr/grinder/drivers/AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2 | tar xvj
  206. ./AMD-APP-SDK-v3.0.130.136-GA-linux64.sh
  207. cd /opt/
  208. if [ -d ADL_SDK ]; then rm -r /opt/ADL_SDK; fi
  209. mkdir ADL_SDK
  210. cd ADL_SDK
  211. wget -c http://wareck.free.fr/grinder/drivers/ADL_SDK102.zip -O ADL_SDK.zip
  212. unzip -q ADL_SDK.zip
  213. cd ~
  214. echo -e "\e[97mDone !\e[0m"
  215. sleep 2
  216. echo -e "\n\e[95mInstall Claymore Dualminer :\e[0m"
  217. cd /home/work/
  218. sudo -u work curl -sf $remote_folder/miners/claymore_dual_$claymore_dual_v.tar.xz | tar xvJ
  219. echo -e "\n\e[95mInstall Claymore Zcash miner:\e[0m"
  220. sudo -u work curl -sf $remote_folder/miners/claymore_zcash_$claymore_zcash_v.tar.xz | tar xvJ
  221. echo -e "\n\e[95mInstall Claymore Xmr miner:\e[0m"
  222. sudo -u work curl -sf $remote_folder/miners/claymore_xmr_$claymore_xmr_v.tar.xz | tar xvJ
  223. echo ""
  224. if [ $NewNiceHash = "YES" ]
  225. then
  226. echo -e "\n\e[95mInstall miner.sh (NewNiceHash) :\e[0m"
  227. cp -v $curdir/miner_new.sh /home/work/miner.sh
  228. else
  229. echo -e "\n\e[95mInstall miner.sh :\e[0m"
  230. cp -v $curdir/miner.sh /home/work/miner.sh
  231. fi
  232. sudo chown work claymore
  233. sudo chown work claymore_xmr
  234. sudo chown work claymore_zcash
  235. sudo chown work /home/work/miner.sh
  236. if [ $Phoenix = "YES" ]
  237. then
  238. echo -e "\n\e[95mInstall Phoenix v$Phoenix_v :\e[0m"
  239. sudo -u work curl -sf $remote_folder/miners/PhoenixMiner_v$Phoenix_v.tar.xz | tar xvJ
  240. sudo chown -R work /home/work/PhoenixMiner
  241. fi
  242. if [ $lolMiner = "YES" ]
  243. then
  244. echo -e "\n\e[95mInstall lolMiner v$lolminer_v :\e[0m"
  245. sudo -u work curl -sf $remote_folder/miners/lolMiner_v$lolminer_v.tar.xz | tar xvJ
  246. sudo chown -R work /home/work/lolMiner
  247. fi
  248. if [ $Gminer = "YES" ]
  249. then
  250. echo -e "\n\e[95mInstall Gminer v$Gminer_v :\e[0m"
  251. sudo -u work curl -sf $remote_folder/miners/gminer_v$Gminer_v.tar.xz | tar xvJ
  252. sudo chown -R work /home/work/gminer
  253. fi
  254. if [ $ETHMine = "YES" ]
  255. then
  256. echo -e "\n\e[95mInstall Ethminer :\e[0m"
  257. cd ~
  258. if [ -d cpp_ethminer ] ; then rm -r cpp_ethminer ;fi
  259. git clone -n https://github.com/ethereum-mining/ethminer.git cpp_ethminer
  260. cd cpp_ethminer
  261. git checkout 2200dca33d35273fb2a7843a7d313a9a31bcd246
  262. cd ~/cpp_ethminer
  263. git submodule update --init --recursive
  264. mkdir build |true
  265. cd build
  266. cmake .. -DETHASHCUDA=OFF -DETHASHCL=ON
  267. make
  268. cd ~
  269. if [ -f ~/ethminer ]; then rm ~/ethminer ;fi
  270. ln -s cpp_ethminer/build/ethminer/ethminer ethminer
  271. cd /tmp
  272. wget http://wareck.free.fr/grinder/cpp_ethminer_kernel.tar.xz
  273. tar xvfJ cpp_ethminer_kernel.tar.xz
  274. sudo mv kernels ~/cpp_ethminer/build/ethminer/
  275. cd ~
  276. echo -e "\e[97mDone !\e[0m"
  277. fi
  278. if [ $SGMINER = "YES" ]
  279. then
  280. echo -e "\n\e[95mInstall Sgminer-Nicehash:\e[0m"
  281. cd ~
  282. if [ ! -d sgminer ]
  283. then
  284. git clone https://github.com/nicehash/sgminer.git
  285. cd sgminer
  286. else
  287. cd sgminer
  288. git pull
  289. fi
  290. sudo apt install git autoconf automake libtool build-essential libncurses5-dev libcurl4-gnutls-dev -y
  291. git submodule init
  292. git submodule update
  293. autoreconf -fi
  294. 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
  295. make -j $(nproc)
  296. cd ~
  297. echo -e "\e[97mDone !\e[0m"
  298. fi
  299. if [ $SGMINER_TT = "YES" ]
  300. then
  301. echo -e "\n\e[95mInstall Sgminer-Timetravel:\e[0m"
  302. cd ~
  303. if [ ! -d sgminer-timetravel ]
  304. then
  305. sudo -u work curl -sf http://wareck.free.fr/openrig/miners/sgminer-timetravel.tar.xz | tar xvJ
  306. cd ~
  307. fi
  308. echo -e "\e[97mDone !\e[0m"
  309. fi
  310. if [ $Lyra2z = "YES" ]
  311. then
  312. echo -e "\n\e[95mInstall Lyra2Z GPU Miner (experimental):\e[0m"
  313. cd ~
  314. if [ -d sgminer-lyra2z ]; then rm -r sgminer-lyra2z ;fi
  315. git clone https://github.com/wareck/sgminer-lyra2z.git
  316. cd ~/sgminer-lyra2z
  317. git pull
  318. git submodule init
  319. git submodule update
  320. ./autogen.sh
  321. 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
  322. make -j $(nproc)
  323. cd ~
  324. echo "Done."
  325. fi
  326. if [ $SGMINER_x16r = "YES" ]
  327. then
  328. echo -e "\n\e[95mInstall Sgminer-x16r :\e[0m"
  329. cd ~
  330. if [ -d sgminer-x16r ]; then rm -r sgminer-x16r;fi
  331. git clone https://github.com/wareck/sgminer-x16r.git
  332. cd ~/sgminer-x16r
  333. git pull
  334. git submodule init
  335. git submodule update
  336. ./autogen.sh
  337. 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
  338. make -j $(nproc)
  339. cd ~
  340. echo "Done."
  341. fi
  342. if [ $XMRIG_AMD = "YES" ]
  343. then
  344. echo -e "\n\e[95mInstall xmrig-amd:\e[0m"
  345. cd ~
  346. if [ -d xmrig_amd ]; then rm -r xmrig_amd ; fi
  347. git clone https://github.com/xmrig/xmrig-amd.git xmrig_amd
  348. cd /tmp/
  349. if ! [ -d libuv ]; then git clone https://github.com/libuv/libuv.git ;fi
  350. cd libuv
  351. ./autogen.sh
  352. ./configure
  353. make -j $(nproc)
  354. sudo make install
  355. sudo ldconfig
  356. cd ~
  357. cd xmrig_amd
  358. if ! [ -f patch_donate.patch ]
  359. then
  360. cat <<'EOF'>> patch_donate.patch
  361. diff --git a/src/donate.h b/src/donate.h
  362. index 46f26b7..67a9cb0 100644
  363. --- a/src/donate.h
  364. +++ b/src/donate.h
  365. @@ -43,8 +43,8 @@
  366. * XMR: 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8n$
  367. * BTC: 1P7ujsXeX7GxQwHNnJsRMgAdNkFZmNVqJT
  368. */
  369. -constexpr const int kDefaultDonateLevel = 5;
  370. -constexpr const int kMinimumDonateLevel = 1;
  371. +constexpr const int kDefaultDonateLevel = 0;
  372. +constexpr const int kMinimumDonateLevel = 0;
  373. #endif /* __DONATE_H__ */
  374. EOF
  375. patch -p1 <patch_donate.patch
  376. fi
  377. if ! [ -d build ];then mkdir build; fi
  378. cd build
  379. cmake ..
  380. make -j $(nproc)
  381. cd ~
  382. if ! [ -f xmrig-amd ]; then ln -s xmrig_amd/build/xmrig-amd xmrig-amd ;fi
  383. echo "Done."
  384. fi
  385. if [ $XMR_STAK = "YES" ]
  386. then
  387. echo -e "\n\e[95mInstall xmr-stak:\e[0m"
  388. cd /tmp/
  389. wget http://wareck.free.fr/grinder/hwloc-1.11.8.tar.xz
  390. tar xvfJ hwloc-1.11.8.tar.xz
  391. cd hwloc-1.11.8
  392. ./autogen.sh
  393. ./configure --prefix=/usr/local
  394. make -j $(nproc)
  395. sudo make install
  396. cd ~
  397. if [ -d xmr_stak ]; then rm -r xmr_stak ;fi
  398. git clone https://github.com/fireice-uk/xmr-stak.git xmr_stak
  399. cd xmr_stak
  400. sudo ln -s /opt/amdgpu-pro/lib/x86_64-linux-gnu/libOpenCL.so /usr/lib/libOpenCL.so.1 | true
  401. mkdir build
  402. sed -i -e "s/= 2.0/= 0.0/g" xmrstak/donate-level.hpp
  403. cd build
  404. cmake .. -DCPU_ENABLE=OFF -DHWLOC_ENABLE=OFF -DMICROHTTPD_ENABLE=OFF -DCMAKE_LINK_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DCUDA_ENABLE=OFF \
  405. -DOpenCL_LIBRARY=/opt/AMDAPPSDK-3.0/lib/x86_64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/opt/AMDAPPSDK-3.0/include/ -DXMR-STAK_COMPILE=generic
  406. make -j $(nproc)
  407. cd ~
  408. if ! [ -f ~/xmr-stak ];then ln -s xmr_stak/build/bin/xmr-stak xmr-stak; fi
  409. sudo cp xmr_stak/build/bin/libxmrstak_opencl_backend.so /lib/
  410. cd ~
  411. if ! [ -f /etc/sysctl.d/60-hugepages.conf ]
  412. then
  413. sudo echo "vm.nr_hugepages=128" > /etc/sysctl.d/60-hugepages.conf
  414. sudo sysctl --system
  415. fi
  416. if ! [ -f /etc/security/limits.d/60-memlock.conf ]
  417. then
  418. sudo echo "* - memlock 262144" >/etc/security/limits.d/60-memlock.conf
  419. sudo echo "root - memlock 262144" >>/etc/security/limits.d/60-memlock.conf
  420. fi
  421. echo "Done"
  422. fi
  423. echo -e "\n\e[95mDownloading NoFees Patch:\e[0m"
  424. cd ~
  425. if [ -d remove_miner_fees ]
  426. then
  427. cd remove_miner_fees
  428. git pull
  429. else
  430. git clone https://github.com/wareck/remove_miner_fees.git
  431. chown -R work remove_miner_fees
  432. fi
  433. if ! [ -f /etc/rc.local ]
  434. then
  435. printf '%s\n' '#!/bin/bash' 'exit 0' | sudo tee -a /etc/rc.local
  436. sudo chmod +x /etc/rc.local
  437. fi
  438. chmod 777 /etc/rc.local
  439. if ! grep --quiet "/home/work/remove_miner_fees" /etc/rc.local
  440. then
  441. sed -i "s/exit 0//g" /etc/rc.local
  442. RC_LOCAL_CMD0="#python /home/work/remove_miner_fees/remove_mining_fees.py &"
  443. RC_LOCAL_CMD1="#python /home/work/remove_miner_fees/zcach.py &"
  444. RC_LOCAL_CMD2="#python /home/work/remove_miner_fees/hush.py &"
  445. RC_LOCAL_CMD3="#python /home/work/remove_miner_fees/ubiq.py &"
  446. RC_LOCAL_CMD4="#python /home/work/remove_miner_fees/soilcoin.py &"
  447. echo $RC_LOCAL_CMD0 >>/etc/rc.local
  448. echo $RC_LOCAL_CMD1 >>/etc/rc.local
  449. echo $RC_LOCAL_CMD2 >>/etc/rc.local
  450. echo $RC_LOCAL_CMD3 >>/etc/rc.local
  451. echo $RC_LOCAL_CMD4 >>/etc/rc.local
  452. echo "exit 0" >>/etc/rc.local
  453. fi
  454. echo -e "\e[97mDone !\e[0m"
  455. echo -e "\n\e[95mInstall AutoStart:\e[0m"
  456. if [ -f /home/work/.config/autostart/miner.sh.desktop ];then rm /home/work/.config/autostart/miner.sh.desktop |true ; fi
  457. if ! [ -d /home/work/.config ]; then mkdir /home/work/.config ;fi
  458. if ! [ -d /home/work/.config/autostart ]; then mkdir /home/work/.config/autostart;fi
  459. cat <<EOF>> /home/work/.config/autostart/miner.sh.desktop
  460. [Desktop Entry]
  461. Type=Application
  462. Exec=/home/work/miner.sh
  463. Hidden=false
  464. NoDisplay=false
  465. X-GNOME-Autostart-enabled=true
  466. Name[fr_FR]=miner
  467. Name=miner
  468. Comment[fr_FR]=miner
  469. Comment=miner
  470. EOF
  471. sleep 5
  472. chmod 777 /etc/rc.local
  473. if ! grep --quiet "su work -c '/home/work/miner.sh'" /etc/rc.local
  474. then
  475. sed -i "s/exit 0//g" /etc/rc.local
  476. RC_LOCAL_CMD0="su work -c '/home/work/miner.sh'"
  477. echo $RC_LOCAL_CMD0 >>/etc/rc.local
  478. echo "exit 0" >>/etc/rc.local
  479. fi
  480. echo -e "\e[97mDone !\e[0m"
  481. cd /home/work/
  482. sudo rm -r tempo
  483. echo -e "\n\e[95mMessage of the day mod :\e[0m"
  484. rm /etc/update-motd.d/00-header | true
  485. rm /etc/update-motd.d/10-help-text |true
  486. rm /etc/update-motd.d/90-updates-available |true
  487. rm /etc/update-motd.d/91-release-upgrade |true
  488. rm /etc/update-motd.d/98-fsck-at-reboot |true
  489. rm /etc/update-motd.d/98-reboot-required |true
  490. echo " - 00-header "
  491. cat <<EOF >> /etc/update-motd.d/00-header
  492. #!/bin/sh
  493. [ -r /etc/lsb-release ] && . /etc/lsb-release
  494. if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
  495. # Fall back to using the very slow lsb_release utility
  496. DISTRIB_DESCRIPTION=$(lsb_release -s -d)
  497. fi
  498. printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" " $(uname -o)" "$(uname -p)"
  499. EOF
  500. cd /etc/update-motd.d
  501. sudo -u work curl -sf http://folivier.homelinux.org/genethos/files/motd.tar.xz | tar xJ
  502. cd ~
  503. sed -i -e "s/#force_color_prompt=yes/force_color_prompt=yes/g" /home/work/.bashrc
  504. if ! grep --quiet "export DISPLAY=:0" /home/work/.bashrc
  505. then
  506. cat <<EOF>> /home/work/.bashrc
  507. export DISPLAY=:0
  508. echo -e "\e[97m
  509. Open Mining Platform \e[96mv$script_version\e[0m
  510. wareck@gmail.com
  511. "
  512. EOF
  513. fi
  514. echo -e "\e[97mDone !\e[0m"
  515. echo -e "\n\e[95mBuilding Swapfile :\e[0m"
  516. if ! grep -q "swapfile" /etc/fstab ; then
  517. case $swap_size in
  518. 0) fst="0";;
  519. 4) sudo dd if=/dev/zero | pv -s 4G | dd of=/swapfile iflag=fullblock bs=1024 count=4194304;;
  520. 8) sudo dd if=/dev/zero | pv -s 8G | dd of=/swapfile iflag=fullblock bs=1024 count=8388608;;
  521. 16) sudo dd if=/dev/zero | pv -s 16G | dd of=/swapfile iflag=fullblock bs=1024 count=16777216 ;;
  522. *) echo -e "\e[91mError in configuration !\e[0m" && exit ;;
  523. esac
  524. if ! [ $swap_size = "0" ]
  525. then
  526. sudo mkswap /swapfile
  527. sudo swapon /swapfile
  528. sudo cat <<'EOF'>> /etc/fstab
  529. /swapfile none swap sw 0 0
  530. EOF
  531. sudo chmod 600 /swapfile
  532. sudo touch /forcefsck
  533. fi
  534. else
  535. echo -e "\e[93mSwapfile already enabled... \e[0m"
  536. echo -e "\e[93mCheck /etc/fsatb file.\e[0m\n"
  537. fi
  538. echo -e "\e[97mDone !\e[0m"
  539. sudo usermod -a -G video work
  540. echo -e "\n\e[95mConfigure Hostname and Rig name:\e[0m"
  541. touch /tmp/hostname
  542. echo $host_name >/tmp/hostname
  543. sudo bash -c 'cp /tmp/hostname /etc/hostname'
  544. sed -i -e "s/digger/$host_name/g" /etc/hosts
  545. # rename rig in miner.sh
  546. sed -i -e "s/OpenRig/$host_name/g" miner.sh
  547. # nano count lines
  548. sed -i -e "s/# set const/set const/g" /etc/nanorc
  549. # reset ssh keys
  550. rm /etc/ssh/ssh_host_*
  551. dpkg-reconfigure openssh-server
  552. sudo apt-get autoremove -y
  553. echo "Done"
  554. echo -e "\n\e[92mEverything was done...\e[0m"
  555. echo -e -n "Reboot in 15 seconds (CRTL+C to abord): "
  556. for i in {15..1}
  557. do
  558. echo -e -n "$i "
  559. sleep 1
  560. done
  561. sudo reboot