setup_amd.sh 18 KB

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