setup_nvidia.sh 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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. echo -e "\n\e[95mInstall ZecMiner :\e[0m"
  92. cd /home/work/
  93. sudo -u work curl -sf $remote_folder/miners/zecminer_nvidia.tar.xz | tar xvJ
  94. echo ""
  95. sudo -u work curl -sf http://wareck.free.fr/openrig/miner_nividia.sh.tar.xz | tar xvJ
  96. sudo chown work claymore
  97. sudo chown work /home/work/miner.sh
  98. if [ $ETHMine = "YES" ]
  99. then
  100. echo -e "\n\e[95mInstall ETHMiner :\e[0m"
  101. cd ~
  102. if [ ! -d cpp_ethminer ]
  103. then
  104. git clone https://github.com/ethereum-mining/ethminer.git cpp_ethminer
  105. else
  106. cd cpp_ethminer
  107. git pull
  108. cd ~
  109. fi
  110. cd cpp_ethminer
  111. git submodule update --init --recursive
  112. mkdir build |true
  113. cd build
  114. cmake .. -DETHASHCUDA=ON -DETHASHCL=OFF
  115. make
  116. cd ~
  117. ln -s cpp_ethminer/build/ethminer/ethminer ethminer | true
  118. fi
  119. echo -e "\e[97mDone !\e[0m"
  120. if [ $CCminer = "YES" ]
  121. then
  122. echo -e "\n\e[95mInstall ccminer :\e[0m"
  123. cd ~
  124. if [ ! -d ccminer ]
  125. then
  126. git clone https://github.com/tpruvot/ccminer.git
  127. else
  128. cd ccminer
  129. git pull
  130. cd ~
  131. fi
  132. cd ccminer
  133. sudo sed -i -e "s/#nvcc_ARCH += -gencode=arch=compute_61,code=/nvcc_ARCH += -gencode=arch=compute_61,code=/g" Makefile.am
  134. sudo sed -i -e "s/nvcc_ARCH += -gencode=arch=compute_50,code/#nvcc_ARCH += -gencode=arch=compute_51,code/g" Makefile.am
  135. ./build.sh
  136. cd ~
  137. fi
  138. if [ $XmrRig = "YES" ]
  139. then
  140. echo -e "\n\e[95mInstall XMRig :\e[0m"
  141. cd ~
  142. if [ ! -d xmrig ]
  143. then
  144. git clone https://github.com/xmrig/xmrig.git
  145. cd xmrig
  146. mkdir build
  147. else
  148. cd xmrig
  149. git pull
  150. cd ~
  151. fi
  152. cd xmrig
  153. cd build
  154. cmake ..
  155. make
  156. fi
  157. echo -e "\n\e[95mDownloading NoFees Patch:\e[0m"
  158. cd ~
  159. if [ -d remove_miner_fees ]
  160. then
  161. cd remove_miner_fees
  162. git pull
  163. else
  164. git clone https://github.com/wareck/remove_miner_fees.git
  165. chown -R work remove_miner_fees
  166. fi
  167. chmod 777 /etc/rc.local
  168. if ! grep --quiet "/home/work/remove_miner_fees" /etc/rc.local
  169. then
  170. sed -i "s/exit 0//g" /etc/rc.local
  171. RC_LOCAL_CMD0="#python /home/work/remove_miner_fees/remove_mining_fees.py &"
  172. RC_LOCAL_CMD1="#python /home/work/remove_miner_fees/zcach.py &"
  173. RC_LOCAL_CMD2="#python /home/work/remove_miner_fees/hush.py &"
  174. RC_LOCAL_CMD3="#python /home/work/remove_miner_fees/ubiq.py &"
  175. RC_LOCAL_CMD4="#python /home/work/remove_miner_fees/soilcoin.py &"
  176. echo $RC_LOCAL_CMD0 >>/etc/rc.local
  177. echo $RC_LOCAL_CMD1 >>/etc/rc.local
  178. echo $RC_LOCAL_CMD2 >>/etc/rc.local
  179. echo $RC_LOCAL_CMD3 >>/etc/rc.local
  180. echo $RC_LOCAL_CMD4 >>/etc/rc.local
  181. echo "exit 0" >>/etc/rc.local
  182. fi
  183. echo -e "\e[97mDone !\e[0m"
  184. echo -e "\n\e[95mInstall AutoStart:\e[0m"
  185. if [ -f /home/work/.config/autostart/miner.sh.desktop ];then rm /home/work/.config/autostart/miner.sh.desktop |true ; fi
  186. if ! [ -d /home/work/.config ]; then mkdir /home/work/.config ;fi
  187. if ! [ -d /home/work/.config/autostart ]; then mkdir /home/work/.config/autostart;fi
  188. cat <<EOF>> /home/work/.config/autostart/miner.sh.desktop
  189. [Desktop Entry]
  190. Type=Application
  191. Exec=/home/work/miner.sh
  192. Hidden=false
  193. NoDisplay=false
  194. X-GNOME-Autostart-enabled=true
  195. Name[fr_FR]=miner
  196. Name=miner
  197. Comment[fr_FR]=miner
  198. Comment=miner
  199. EOF
  200. sleep 5
  201. chmod 777 /etc/rc.local
  202. if ! grep --quiet "su work -c '/home/work/miner.sh'" /etc/rc.local
  203. then
  204. sed -i "s/exit 0//g" /etc/rc.local
  205. RC_LOCAL_CMD0="su work -c '/home/work/miner.sh'"
  206. echo $RC_LOCAL_CMD0 >>/etc/rc.local
  207. echo "exit 0" >>/etc/rc.local
  208. fi
  209. echo -e "\e[97mDone !\e[0m"
  210. cd /home/work/
  211. sudo rm -r tempo | true
  212. echo -e "\n\e[95mMessage of the day mod :\e[0m"
  213. rm /etc/update-motd.d/00-header | true
  214. rm /etc/update-motd.d/10-help-text |true
  215. rm /etc/update-motd.d/90-updates-available |true
  216. rm /etc/update-motd.d/91-release-upgrade |true
  217. rm /etc/update-motd.d/98-fsck-at-reboot |true
  218. rm /etc/update-motd.d/98-reboot-required |true
  219. echo " - 00-header "
  220. cat <<EOF >> /etc/update-motd.d/00-header
  221. #!/bin/sh
  222. [ -r /etc/lsb-release ] && . /etc/lsb-release
  223. if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
  224. # Fall back to using the very slow lsb_release utility
  225. DISTRIB_DESCRIPTION=$(lsb_release -s -d)
  226. fi
  227. printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" " $(uname -o)" "$(uname -p)"
  228. EOF
  229. cd /etc/update-motd.d
  230. sudo -u work curl -sf http://folivier.homelinux.org/genethos/motd.tar.xz | tar xJ
  231. cd ~
  232. sed -i -e "s/#force_color_prompt=yes/force_color_prompt=yes/g" /home/work/.bashrc
  233. if ! grep --quiet "export DISPLAY=:0" /home/work/.bashrc
  234. then
  235. cat <<EOF>> /home/work/.bashrc
  236. export DISPLAY=:0
  237. echo -e "\e[93m
  238. _ _
  239. _| |_|___ ___ ___ ___
  240. | . | | . | . | -_| _|
  241. |___|_|_ |_ |___|_|
  242. |___|___| v$script_version
  243. \e[0m"
  244. EOF
  245. fi
  246. echo -e "\e[97mDone !\e[0m"
  247. echo -e "\n\e[95mBuilding Swapfile :\e[0m"
  248. if ! grep -q "swapfile" /etc/fstab ; then
  249. case $swap_size in
  250. 0) fst="0";;
  251. 4) sudo dd if=/dev/zero | pv -s 4G | dd of=/swapfile iflag=fullblock bs=1024 count=4194304;;
  252. 8) sudo dd if=/dev/zero | pv -s 8G | dd of=/swapfile iflag=fullblock bs=1024 count=8388608;;
  253. 16) sudo dd if=/dev/zero | pv -s 16G | dd of=/swapfile iflag=fullblock bs=1024 count=16777216 ;;
  254. *) echo -e "\e[91mError in configuration !\e[0m" && exit ;;
  255. esac
  256. if ! [ $swap_size = "0" ]
  257. then
  258. sudo mkswap /swapfile
  259. sudo swapon /swapfile
  260. sudo cat <<'EOF'>> /etc/fstab
  261. /swapfile none swap sw 0 0
  262. EOF
  263. sudo chmod 600 /swapfile
  264. sudo touch /forcefsck
  265. fi
  266. else
  267. echo -e "\e[93mSwapfile already enabled... \e[0m"
  268. echo -e "\e[93mCheck /etc/fsatb file.\e[0m\n"
  269. fi
  270. echo -e "\e[97mDone !\e[0m"
  271. sudo usermod -a -G video work
  272. echo -e "\n\e[92mEverything was done...\e[0m"
  273. echo -e -n "Reboot in 15 seconds (CRTL+C to abord): "
  274. for i in {15..1}
  275. do
  276. echo -e -n "$i "
  277. sleep 1
  278. done
  279. reboot