setup_amd.sh 15 KB

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