setup_nvidia.sh 8.8 KB

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