setup_nvidia.sh 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. #!/bin/bash
  2. set -e
  3. script_version="1.50b"
  4. rdate="24/12/2018"
  5. remote_folder="http://wareck.free.fr/openrig"
  6. cuda="9.2" # 9.2 or 8
  7. #### OPTIONS ####
  8. ETHMine="YES"
  9. CCminer="YES"
  10. XmrRig="YES"
  11. XmrStak="YES"
  12. Zecminer="YES"
  13. swap_size="0" # 0/4/8/16 Go
  14. #script_version=`grep version version.txt | awk '{ print $2 }'`
  15. #rdate=`grep release version.txt | awk '{ print $2 }'`
  16. if [ $UID -ne 0 ]
  17. then
  18. echo -e "\n\e[91mPlease run this script as ROOT : sudo ./setup.sh \e[0m"
  19. echo
  20. sleep 1
  21. exit
  22. fi
  23. claymore_dual_v="`curl -s $remote_folder/version.txt | awk 'NR==1 {print$3; exit}'`"
  24. claymore_zcash_v="`curl -s $remote_folder/version.txt | awk 'NR==2 {print$3; exit}'`"
  25. claymore_xmr_v="`curl -s $remote_folder/version.txt | awk 'NR==3 {print$3; exit}'`"
  26. echo ""
  27. echo -n -e " \e[97m\u2554"
  28. for i in {1..41}; do echo -e -n "\u2550"; done
  29. echo -e "\u2557\e[0m"
  30. echo -e " \e[97m\u2551 NVIDIA Mining Rig Auto-install \e[93m"V$script_version"\e[0m\e[97m \u2551\e[0m"
  31. echo -e " \e[97m\u2551 Release date: \e[93m"$rdate"\e[0m\e[97m \u2551\e[0m"
  32. echo -e " \e[97m\u2551 wareck@gmail.com \u2551\e[0m"
  33. echo -n -e " \e[97m\u255A"
  34. for j in {1..41}; do echo -e -n "\u2550";done
  35. echo -e -n "\u255D\e[0m"
  36. echo
  37. echo -e "\e[97m +\e[91m Cuda toolkit v$cuda \e[0m\e[97m"
  38. if [ $ETHMine = "YES" ]; then echo -e "\e[97m +\e[91m Etherminer \e[0m\e[97m";fi
  39. if [ $CCminer = "YES" ]; then echo -e "\e[97m +\e[91m CCminer \e[0m\e[97m";fi
  40. if [ $XmrRig = "YES" ]; then echo -e "\e[97m +\e[91m XMR_Rig \e[0m\e[97m";fi
  41. if [ $XmrStak = "YES" ]; then echo -e "\e[97m +\e[91m XMR_Stak \e[0m\e[97m";fi
  42. if [ $Zecminer = "YES" ]; then echo -e "\e[97m +\e[91m Ewbf_Zecminer \e[0m\e[97m";fi
  43. if [ $Zecminer = "YES" ]; then echo -e "\e[97m +\e[91m Ewbf_Zecminer_mod \e[0m\e[97m";fi
  44. echo -e "\e[97m +\e[91m Claymore dualminer $claymore_dual_v\e[0m\e[97m"
  45. sleep 4
  46. sed -i -e "s/# set const/set const/g" /etc/nanorc
  47. echo -e "\n\e[95mExpand Disk :\e[0m"
  48. sudo growpart `df -h | grep /dev/sd | awk ' { print $1 }'| cut -c -8` 1 |true
  49. sudo resize2fs `df -h | grep /dev/sd | awk ' { print $1 }'` |true
  50. echo -e "\e[97mDone !\e[0m"
  51. echo -e "\n\e[95mSystem Update :\e[0m"
  52. #sudo apt-get update
  53. #sudo add-apt-repository -y ppa:ethereum/ethereum -y
  54. sudo apt-get update
  55. sudo apt install git screen htop curl ntp pv git cmake libleveldb-dev libjsoncpp-dev \
  56. build-essential libcurl4-gnutls-dev libgmp-dev libtool \
  57. libreadline-dev libmicrohttpd-dev libjansson-dev libgmp-dev libssl-dev unzip python-nfqueue python-scapy -y
  58. if [ $CCminer = "YES" ]
  59. then
  60. sudo apt-get install libcurl4-openssl-dev libssl-dev libjansson-dev automake autotools-dev build-essential -y
  61. fi
  62. if [ $XmrRig = "YES" ]
  63. then
  64. sudo apt-get install git build-essential cmake libuv1-dev libmicrohttpd-dev -y
  65. fi
  66. cd ~
  67. sleep 5
  68. sudo sed -i -e "s/quiet splash/text/g" /etc/default/grub
  69. sudo sed -i -e 's#GRUB_CMDLINE_LINUX=""#GRUB_CMDLINE_LINUX="amddgpu.vm_fragment_size=9"#g' /etc/default/grub
  70. sudo update-grub2
  71. sudo apt dist-upgrade -y
  72. echo -e "\n\e[95mInstall Nvidia Drivers :\e[0m"
  73. sudo add-apt-repository ppa:graphics-drivers/ppa -y
  74. sudo apt-get update
  75. sudo apt-get install nvidia-396 -y
  76. cd /tmp
  77. if [ $cuda = "9.2" ]
  78. then
  79. wget -c http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.2.148-1_amd64.deb
  80. sudo dpkg -i cuda-repo-ubuntu1604_9.2.148-1_amd64.deb
  81. sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
  82. sudo apt-get update
  83. sudo apt-get install cuda -y
  84. fi
  85. if [ $cuda = "8" ]
  86. then
  87. wget -c https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
  88. sudo dpkg -i cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
  89. sudo apt-get update
  90. sudo apt-get install cuda-8-0 -y
  91. fi
  92. echo -e "\n\e[95mInstall script miner.sh :\e[0m"
  93. cd ~
  94. sudo -u work curl -sf http://wareck.free.fr/openrig/files/miner_nvidia.sh.tar.xz | tar xvJ
  95. sudo chown work /home/work/miner.sh
  96. echo -e "\n\e[95mInstall Claymore Miners :\e[0m"
  97. cd ~
  98. sudo -u work curl -sf $remote_folder/miners/claymore_dual_$claymore_dual_v.tar.xz | tar xvJ
  99. sudo chown work claymore
  100. echo ""
  101. if [ $Zecminer = "YES" ]
  102. then
  103. echo -e "\n\e[95mInstall ZecMiner :\e[0m"
  104. cd ~
  105. sudo -u work curl -sf $remote_folder/miners/zecminer_nvidia.tar.xz | tar xvJ
  106. echo -e "\n\e[95mInstall ZecMiner_mod :\e[0m"
  107. if [ $cuda = "8" ]
  108. then
  109. sudo -u work curl -sf $remote_folder/miners/zecminer_nvidia_mod_cuda8.tar.xz | tar xvJ
  110. else
  111. sudo -u work curl -sf $remote_folder/miners/zecminer_nvidia_mod_cuda9.tar.xz | tar xvJ
  112. fi
  113. echo ""
  114. fi
  115. if [ $ETHMine = "YES" ]
  116. then
  117. echo -e "\n\e[95mInstall ETHMiner :\e[0m"
  118. cd ~
  119. if [ ! -d cpp_ethminer ]
  120. then
  121. git clone -n https://github.com/ethereum-mining/ethminer.git cpp_ethminer
  122. cd cpp_ethminer
  123. git checkout 2200dca33d35273fb2a7843a7d313a9a31bcd246
  124. else
  125. cd cpp_ethminer
  126. git pull
  127. cd ~
  128. fi
  129. cd ~/cpp_ethminer
  130. git submodule update --init --recursive
  131. mkdir build |true
  132. cd build
  133. cmake .. -DETHASHCUDA=ON -DETHASHCL=OFF
  134. make
  135. cd ~
  136. ln -s cpp_ethminer/build/ethminer/ethminer ethminer | true
  137. fi
  138. if ! [ -d cpp_ethminer/build/ethminer/kernels ]
  139. then
  140. cd /tmp
  141. wget http://wareck.free.fr/grinder/cpp_ethminer_kernel.tar.xz
  142. tar xvfJ cpp_ethminer_kernel.tar.xz
  143. sudo cp kernels ~/cpp_ethminer/build/ethminer/ | true
  144. fi
  145. cd ~
  146. echo -e "\e[97mDone !\e[0m"
  147. if [ $CCminer = "YES" ]
  148. then
  149. echo -e "\n\e[95mInstall ccminer :\e[0m"
  150. cd ~
  151. if [ ! -d ccminer ]
  152. then
  153. git clone https://github.com/tpruvot/ccminer.git
  154. cd ccminer
  155. sudo sed -i -e "s/#nvcc_ARCH += -gencode=arch=compute_61,code=/nvcc_ARCH += -gencode=arch=compute_61,code=/g" Makefile.am
  156. sudo sed -i -e "s/nvcc_ARCH += -gencode=arch=compute_50,code/#nvcc_ARCH += -gencode=arch=compute_51,code/g" Makefile.am
  157. ./build.sh
  158. else
  159. cd ccminer
  160. git pull
  161. make -j $(nproc)
  162. fi
  163. fi
  164. if [ $XmrRig = "YES" ]
  165. then
  166. echo -e "\n\e[95mInstall XMRig :\e[0m"
  167. cd ~
  168. if ! [ -d xmrig ]
  169. then
  170. git clone https://github.com/xmrig/xmrig.git
  171. else
  172. cd xmrig
  173. git pull
  174. fi
  175. cd ~/xmrig
  176. mkdir build | true
  177. cd build
  178. cmake ..
  179. make -j $(nproc)
  180. fi
  181. if [ $XmrStak = "YES" ]
  182. then
  183. echo -e "\n\e[93mBuiling XMR-stak $xmr_stak_v:\e[0m"
  184. cd /tmp/
  185. wget http://wareck.free.fr/grinder/hwloc-1.11.8.tar.xz
  186. tar xvfJ hwloc-1.11.8.tar.xz
  187. cd hwloc-1.11.8
  188. ./autogen.sh
  189. ./configure --prefix=/usr/local
  190. make -j $(nproc)
  191. sudo make install
  192. cd ~
  193. if ! [ -d xmr-stak ];then git clone https://github.com/fireice-uk/xmr-stak.git;fi
  194. chown -R work xmr-stak
  195. cd xmr-stak
  196. git pull
  197. if [ -d build ]
  198. then
  199. rm -r build
  200. fi
  201. mkdir build
  202. sed -i -e "s/= 2.0/= 0.0/g" xmrstak/donate-level.hpp
  203. cd build
  204. cmake -DCUDA_ENABLE=ON -DHWLOC_ENABLE=OFF -DCPU_ENABLE=OFF -DOpenCL_ENABLE=OFF -DOpenSSL_ENABLE=ON -DMICROHTTPD_ENABLE=OFF -DCMAKE_LINK_STATIC=ON ..
  205. sleep 2
  206. make -j $(nproc)
  207. cd ~
  208. if [ -f ~/xmr-miner ];
  209. then
  210. sudo rm ~/xmr-miner;
  211. fi
  212. ln -s xmr-stak/build/bin/xmr-stak ~/xmr-miner | true
  213. if ! [ -L /usr/lib/x86_64-linux-gnu/libxmrstak_cuda_backend.so ]
  214. then
  215. sudo cp xmr-stak/build/bin/libxmrstak_cuda_backend.so /usr/lib/x86_64-linux-gnu/libxmrstak_cuda_backend.so |true
  216. sudo cp xmr-stak/build/bin/libxmr-stak-c.a /usr/lib/x86_64-linux-gnu/ |true
  217. sudo cp xmr-stak/build/bin/libxmr-stak-backend.a /usr/lib/x86_64-linux-gnu/ |true
  218. fi
  219. echo
  220. sleep 2
  221. if ! grep -q "vm.nr_hugepages=256" /etc/sysctl.conf
  222. then
  223. sudo bash -c 'echo "vm.nr_hugepages=256" >> /etc/sysctl.conf'
  224. sudo bash -c 'sysctl -p'
  225. fi
  226. fi
  227. echo -e "\n\e[95mDownloading NoFees Patch:\e[0m"
  228. cd ~
  229. if [ -d remove_miner_fees ]
  230. then
  231. cd remove_miner_fees
  232. git pull
  233. else
  234. git clone https://github.com/wareck/remove_miner_fees.git
  235. chown -R work remove_miner_fees
  236. fi
  237. chmod 777 /etc/rc.local
  238. if ! grep --quiet "/home/work/remove_miner_fees" /etc/rc.local
  239. then
  240. sed -i "s/exit 0//g" /etc/rc.local
  241. RC_LOCAL_CMD0="#python /home/work/remove_miner_fees/remove_mining_fees.py &"
  242. RC_LOCAL_CMD1="#python /home/work/remove_miner_fees/zcach.py &"
  243. RC_LOCAL_CMD2="#python /home/work/remove_miner_fees/hush.py &"
  244. RC_LOCAL_CMD3="#python /home/work/remove_miner_fees/ubiq.py &"
  245. RC_LOCAL_CMD4="#python /home/work/remove_miner_fees/soilcoin.py &"
  246. echo $RC_LOCAL_CMD0 >>/etc/rc.local
  247. echo $RC_LOCAL_CMD1 >>/etc/rc.local
  248. echo $RC_LOCAL_CMD2 >>/etc/rc.local
  249. echo $RC_LOCAL_CMD3 >>/etc/rc.local
  250. echo $RC_LOCAL_CMD4 >>/etc/rc.local
  251. echo "exit 0" >>/etc/rc.local
  252. fi
  253. echo -e "\e[97mDone !\e[0m"
  254. echo -e "\n\e[95mInstall AutoStart:\e[0m"
  255. if [ -f /home/work/.config/autostart/miner.sh.desktop ];then rm /home/work/.config/autostart/miner.sh.desktop |true ; fi
  256. if ! [ -d /home/work/.config ]; then mkdir /home/work/.config ;fi
  257. if ! [ -d /home/work/.config/autostart ]; then mkdir /home/work/.config/autostart;fi
  258. cat <<EOF>> /home/work/.config/autostart/miner.sh.desktop
  259. [Desktop Entry]
  260. Type=Application
  261. Exec=/home/work/miner.sh
  262. Hidden=false
  263. NoDisplay=false
  264. X-GNOME-Autostart-enabled=true
  265. Name[fr_FR]=miner
  266. Name=miner
  267. Comment[fr_FR]=miner
  268. Comment=miner
  269. EOF
  270. sleep 5
  271. chmod 777 /etc/rc.local
  272. if ! grep --quiet "su work -c '/home/work/miner.sh'" /etc/rc.local
  273. then
  274. sed -i "s/exit 0//g" /etc/rc.local
  275. RC_LOCAL_CMD0="su work -c '/home/work/miner.sh'"
  276. echo $RC_LOCAL_CMD0 >>/etc/rc.local
  277. echo "exit 0" >>/etc/rc.local
  278. fi
  279. echo -e "\e[97mDone !\e[0m"
  280. echo -e "\n\e[95mMessage of the day mod :\e[0m"
  281. rm /etc/update-motd.d/00-header | true
  282. rm /etc/update-motd.d/10-help-text |true
  283. rm /etc/update-motd.d/90-updates-available |true
  284. rm /etc/update-motd.d/91-release-upgrade |true
  285. rm /etc/update-motd.d/98-fsck-at-reboot |true
  286. rm /etc/update-motd.d/98-reboot-required |true
  287. echo " - 00-header "
  288. cat <<EOF >> /etc/update-motd.d/00-header
  289. #!/bin/sh
  290. [ -r /etc/lsb-release ] && . /etc/lsb-release
  291. if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
  292. # Fall back to using the very slow lsb_release utility
  293. DISTRIB_DESCRIPTION=$(lsb_release -s -d)
  294. fi
  295. printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" " $(uname -o)" "$(uname -p)"
  296. EOF
  297. cd /etc/update-motd.d
  298. sudo -u work curl -sf http://folivier.homelinux.org/genethos/files/motd.tar.xz | tar xJ
  299. cd ~
  300. sed -i -e "s/#force_color_prompt=yes/force_color_prompt=yes/g" /home/work/.bashrc
  301. if ! grep --quiet "export DISPLAY=:0" /home/work/.bashrc
  302. then
  303. cat <<EOF>> /home/work/.bashrc
  304. export DISPLAY=:0
  305. echo -e "\e[93m
  306. _ _
  307. _| |_|___ ___ ___ ___
  308. | . | | . | . | -_| _|
  309. |___|_|_ |_ |___|_|
  310. |___|___| v$script_version
  311. \e[0m"
  312. EOF
  313. fi
  314. echo -e "\e[97mDone !\e[0m"
  315. echo -e "\n\e[95mBuilding Swapfile :\e[0m"
  316. if ! grep -q "swapfile" /etc/fstab ; then
  317. case $swap_size in
  318. 0) fst="0";;
  319. 4) sudo dd if=/dev/zero | pv -s 4G | dd of=/swapfile iflag=fullblock bs=1024 count=4194304;;
  320. 8) sudo dd if=/dev/zero | pv -s 8G | dd of=/swapfile iflag=fullblock bs=1024 count=8388608;;
  321. 16) sudo dd if=/dev/zero | pv -s 16G | dd of=/swapfile iflag=fullblock bs=1024 count=16777216 ;;
  322. *) echo -e "\e[91mError in configuration !\e[0m" && exit ;;
  323. esac
  324. if ! [ $swap_size = "0" ]
  325. then
  326. sudo mkswap /swapfile
  327. sudo swapon /swapfile
  328. sudo cat <<'EOF'>> /etc/fstab
  329. /swapfile none swap sw 0 0
  330. EOF
  331. sudo chmod 600 /swapfile
  332. sudo touch /forcefsck
  333. fi
  334. else
  335. echo -e "\e[93mSwapfile already enabled... \e[0m"
  336. echo -e "\e[93mCheck /etc/fsatb file.\e[0m\n"
  337. fi
  338. echo -e "\e[97mDone !\e[0m"
  339. sudo usermod -a -G video work
  340. echo -e "\n\e[92mEverything was done...\e[0m"
  341. echo -e -n "Reboot in 15 seconds (CRTL+C to abord): "
  342. for i in {15..1}
  343. do
  344. echo -e -n "$i "
  345. sleep 1
  346. done
  347. reboot