setup_amd.sh 16 KB

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