setup_amd.sh 17 KB

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