setup_amd.sh 15 KB

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