setup_nvidia.sh 8.0 KB

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