setup_amd.sh 18 KB

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