build_cube.sh 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951
  1. #!/bin/bash
  2. set -e
  3. Version=18.4.1
  4. Cuda=YES
  5. kernel_custom=YES
  6. Miners=Yes
  7. Webmin="webmin-2.105"
  8. kernel_dkms="5.15.0-71-generic"
  9. driver=NVIDIA
  10. if (( $EUID != 0 )); then
  11. echo -e "$(tput setaf 11)This must be run as root. Try 'sudo $0'.$(tput sgr0)"
  12. exit 1
  13. fi
  14. clear
  15. if [ ! -f /home/wareck/.ipass ]
  16. then
  17. echo "passe=1" > /home/wareck/.ipass
  18. fi
  19. source /home/wareck/.ipass
  20. export TERM=xterm-256color
  21. Cuda=${Cuda^^}
  22. kernel_custom=${kernel_custom^^}
  23. driver=${driver^^}
  24. Miners=${Miners^^}
  25. cpass=""
  26. function ubuntu_version_check {
  27. if [[ $(lsb_release -rs) == "20.04" ]]
  28. then
  29. Ubuntu_version="20.04.6"
  30. else
  31. echo "Non-compatible version !"
  32. exit 0
  33. fi
  34. }
  35. function print_centered {
  36. [[ $# == 0 ]] && return 1
  37. declare -i TERM_COLS="$(tput cols)"
  38. declare -i str_len="${#1}"
  39. [[ $str_len -ge $TERM_COLS ]] && {
  40. echo "$1";
  41. return 0;
  42. }
  43. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  44. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  45. filler=""
  46. for (( i = 0; i < filler_len; i++ )); do
  47. filler="${filler}${ch}"
  48. done
  49. printf "%s%s%s" "$filler" "$1" "$filler"
  50. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  51. printf "\n"
  52. return 0
  53. }
  54. function decompte_ {
  55. echo -e "$(tput setaf 10)\nReboot in 10 seconds (CRTL+C to abord):$(tput sgr0)"
  56. for i in {9..0}
  57. do
  58. echo -e -n "$i "
  59. sleep 1
  60. done
  61. echo ""
  62. sudo reboot
  63. }
  64. function intro_ {
  65. print_centered "$(tput setaf 5)"
  66. print_centered " ██████╗██╗ ██╗██████╗ ███████╗"
  67. print_centered "██╔════╝██║ ██║██╔══██╗██╔════╝"
  68. print_centered "██║ ██║ ██║██████╔╝█████╗ "
  69. print_centered "██║ ██║ ██║██╔══██╗██╔══╝ "
  70. print_centered "╚██████╗╚██████╔╝██████╔╝███████╗"
  71. print_centered " ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝"
  72. echo -n "$(tput sgr0)"
  73. print_centered "Cube Server installation script v$Version"
  74. print_centered "Ubuntu version 20.04.6"
  75. if [ $Cuda = "YES" ]
  76. then
  77. print_centered "CUDA Compute Drivers"
  78. fi
  79. print_centered "Stage $passe/4"
  80. }
  81. function update_ {
  82. case $passe in
  83. 1)
  84. echo -e "$(tput setaf 10)\nUpdate and install packages (second pass):$(tput sgr0)"
  85. sudo apt-get update
  86. echo -e ""
  87. sudo apt-get install lxde lxde-icon-theme -y
  88. echo -e ""
  89. sudo apt-get install samba cifs-utils mdadm git build-essential libtool pkg-config automake autoconf ethtool net-tools openvpn filezilla \
  90. tasksel lzma-dev lzma cmake libuv1-dev libssl-dev msr-tools tightvncserver lm-sensors openssh-server xfsprogs -y
  91. echo -e ""
  92. sudo apt-get install zstd pixz pbzip2 pigz btrfs-progs gparted gpart gnome-remote-desktop libcanberra-gtk-module \
  93. ctorrent libcurl4-openssl-dev bison byacc screen libudev-dev libjansson-dev libncurses5-dev libmicrohttpd-dev curl nvme-cli -y
  94. echo -e ""
  95. sudo apt-get install libglib2.0-dev libgtk2.0-dev libsensors4-dev htop vlc locate cmake -y
  96. echo -e "Done."
  97. ;;
  98. 2)
  99. if [ $Cuda = "YES" ]
  100. then
  101. echo -e "$(tput setaf 10)\nInstall Cuda packages:$(tput sgr0)"
  102. sudo apt-get install libgmp-dev libnuma-dev cmake libuv1-dev nvidia-cuda-dev libmicrohttpd-dev gcc-8 g++-8 nvidia-cuda-toolkit -y
  103. fi
  104. echo -e "Done.\n"
  105. ;;
  106. esac
  107. }
  108. function kernel_check_ {
  109. unamestr=$(uname -r)
  110. if [ -f /tmp/ksource.txt ]; then rm /tmp/ksource.txt;fi
  111. wget -c -q http://192.168.1.8:3000/wareck/custom_kernel/raw/master/ksource.txt -O /tmp/ksource.txt
  112. source /tmp/ksource.txt
  113. if ! [[ "$unamestr" == $KLversion ]]
  114. then
  115. echo -e "\n$(tput setaf 10)Custom kernel install $(tput setaf 9)$KLversion$(tput setaf 10) (fix DKMS/WOL) :$(tput sgr0)"
  116. cd /tmp/
  117. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/custom_kernel/$kernel_version
  118. chmod +x $kernel_version
  119. sudo ./$kernel_version
  120. if ! [ -f /etc/modprobe.d/blacklist-nvidia-nouveau.conf ]
  121. then
  122. echo "Blacklist nvidia-nouveau driver..."
  123. echo "System will reboot"
  124. sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
  125. sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
  126. fi
  127. fi
  128. }
  129. function nvidia_driver_ {
  130. if [ $passe = "1" ]
  131. then
  132. if ! [ -f /etc/modprobe.d/blacklist-nvidia-nouveau.conf ]
  133. then
  134. echo "Blacklist nvidia-nouveau driver..."
  135. echo "System will reboot"
  136. sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
  137. sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
  138. fi
  139. if [ $Cuda = "NO" ]
  140. then
  141. sudo apt-get install build-essential libglvnd-dev cmake -y
  142. else
  143. sudo apt-get install build-essential libglvnd-dev cmake libhugetlbfs-dev libc-dev libc6-dev g++ -y
  144. fi
  145. echo "passe=2" > /home/wareck/.ipass
  146. decompte_
  147. fi
  148. if [ $passe = "2" ]
  149. then
  150. case $Cuda in
  151. NO)
  152. echo -e "$(tput setaf 10)\nInstall NVIDIA GTX1080 Drivers :$(tput sgr0)"
  153. sleep 3
  154. sudo apt-get install nvidia-driver-525 -y
  155. touch /home/wareck/.pass2
  156. decompte_
  157. ;;
  158. YES)
  159. echo -e "$(tput setaf 10)\nInstall CUDA Drivers :$(tput sgr0)"
  160. cd /home/wareck/
  161. echo -e "Download MegaDownload:"
  162. git clone https://github.com/wareck/megadown.git
  163. sudo cp /home/wareck/megadown/megadown /usr/local/bin/megadown
  164. sudo rm -r /home/wareck/megadown
  165. #megadown https://mega.nz/file/r0wwnZCJ#27WWRMwSsGYXiMUHf2OgcGYp2O2itChsBxcK9znmr5E
  166. #chmod +x cuda_11.8.0_520.61.05_linux.run
  167. #sudo ./cuda_11.8.0_520.61.05_linux.run
  168. #sudo rm cuda_11.8.0_520.61.05_linux.run
  169. #wget -c https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux.run
  170. #megadown https://mega.nz/file/u9h1wbYL#QuHtEpCErWXDFjjMVFTK9QzcAI5SrsgTMbx6DfFJT2k
  171. #wget https://developer.download.nvidia.com/compute/cuda/12.3.0/local_installers/cuda_12.3.0_545.23.06_linux.run
  172. wget -c https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda_12.4.1_550.54.15_linux.run
  173. chmod +x cuda_12.4.1_550.54.15_linux.run
  174. sudo ./cuda_12.4.1_550.54.15_linux.run --silent --driver --toolkit
  175. sudo rm cuda_12.4.1_550.54.15_linux.run
  176. echo "passe=3" > /home/wareck/.ipass
  177. decompte_
  178. ;;
  179. esac
  180. fi
  181. }
  182. function download_packs_ {
  183. echo -e "$(tput setaf 10)\nDownload complement packs:$(tput sgr0)"
  184. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/cgminer.conf -O /home/wareck/Build_Cube/pack/cgminer.conf
  185. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/chia-miner.tar.xz -O /home/wareck/Build_Cube/pack/chia-miner.tar.xz
  186. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/gerbera.tar.xz -O /home/wareck/Build_Cube/pack/gerbera.tar.xz
  187. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/start_cgminer.tar.xz -O /home/wareck/Build_Cube/pack/start_cgminer.tar.xz
  188. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/$Webmin.tar.xz -O /home/wareck/Build_Cube/pack/$Webmin.tar.xz
  189. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/xmrig.tar.xz -O /home/wareck/Build_Cube/pack/xmrig.tar.xz
  190. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/zfsmanager-0.0.4.wbm.gz -O /home/wareck/Build_Cube/pack/zfsmanager-0.0.4.wbm.gz
  191. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/gpu-miners.tar.xz -O /home/wareck/Build_Cube/pack/gpu-miners.tar.xz
  192. cp /home/wareck/Build_Cube/pack/gpu-miners.tar.xz /home/wareck
  193. cp /home/wareck/Build_Cube/pack/pack1.tar.xz /home/wareck
  194. cp /home/wareck/Build_Cube/pack/pack2.tar.xz /home/wareck
  195. cp /home/wareck/Build_Cube/pack/pack3.tar.xz /home/wareck
  196. cp /home/wareck/Build_Cube/pack/xmrig.tar.xz /home/wareck
  197. cp /home/wareck/Build_Cube/pack/start_cgminer.tar.xz /home/wareck
  198. echo -e "Done."
  199. if [ ! -d /home/wareck/$Webmin ]
  200. then
  201. cp /home/wareck/Build_Cube/pack/$Webmin.tar.xz /home/wareck/
  202. cd /home/wareck/
  203. echo -e "$(tput setaf 10)\nWebmin uncompress:$(tput sgr0)"
  204. tar xfJ $Webmin.tar.xz
  205. rm $Webmin.tar.xz
  206. echo -e "Done"
  207. fi
  208. echo -e "$(tput setaf 10)\nDownloading miners:$(tput sgr0)"
  209. cd /home/wareck
  210. if ! [ -d miners ]; then mkdir -p miners;fi
  211. cd /home/wareck/miners
  212. if ! [ -d xmrig ]
  213. then
  214. git clone https://github.com/xmrig/xmrig.git
  215. echo -e ""
  216. fi
  217. #if ! [ -d xmr-stak ]
  218. #then
  219. #git clone https://github.com/fireice-uk/xmr-stak.git
  220. #echo -e ""
  221. #fi
  222. #if ! [ -d xmr-stak-rx ]
  223. #then
  224. #git clone https://github.com/fireice-uk/xmr-stak.git -b xmr-stak-rx xmr-stak-rx
  225. #echo -e ""
  226. #fi
  227. if ! [ -d cgminer-gekko ]
  228. then
  229. git clone https://github.com/wareck/cgminer-gekko.git
  230. echo -e ""
  231. fi
  232. if ! [ -d cgminer-lketc ]
  233. then
  234. git clone https://github.com/wareck/cgminer-lketc.git
  235. fi
  236. echo -e "Done.\n"
  237. }
  238. function build_miners_ {
  239. cmake_ #check cmake version
  240. cd /home/wareck
  241. tar xfJ gpu-miners.tar.xz
  242. cd /home/wareck/miners
  243. echo -e "$(tput setaf 10)\nBuild Cgminer-gekko:$(tput sgr0)"
  244. cd cgminer-gekko
  245. sudo usermod -a -G dialout,plugdev wareck
  246. sudo cp 01-cgminer.rules /etc/udev/rules.d/
  247. CFLAGS="-O2 -march=native" ./autogen.sh
  248. ./configure --enable-gekko
  249. make -j$((`nproc`+1))
  250. tar xfJ /home/wareck/start_cgminer.tar.xz
  251. rm /home/wareck/start_cgminer.tar.xz
  252. cd ..
  253. cat <<'EOF'>> /tmp/cgminer
  254. #!/bin/sh -e
  255. ### BEGIN INIT INFO
  256. # Provides: cgminer
  257. # Required-Start: networking
  258. # Default-Start: 3 4 5
  259. # Default-Stop: 0 6
  260. ### END INIT INFO
  261. case "$1" in
  262. start)
  263. cd /home/wareck/miners/cgminer-gekko/
  264. su wareck -c "screen -dmS cgminer /home/wareck/miners/cgminer-gekko/cgminer"
  265. ;;
  266. stop)
  267. sudo killall -9 cgminer | true
  268. ;;
  269. *)
  270. echo "Usage: /etc/init.d/cgminer {start|stop}"
  271. exit 1
  272. ;;
  273. esac
  274. exit 0
  275. EOF
  276. chmod +x /tmp/cgminer
  277. sudo cp /tmp/cgminer /etc/init.d/cgminer
  278. sudo update-rc.d cgminer defaults
  279. if ! [ -d /home/wareck/.cgminer ]
  280. then
  281. mkdir /home/wareck/.cgminer
  282. fi
  283. cat <<'EOF'>> /tmp/cgminer.conf
  284. {
  285. "pools" : [
  286. {
  287. "url" : "stratum+tcp://stratum.braiins.com:3333",
  288. "user" : "wareck.gekko",
  289. "pass" : "x"
  290. }
  291. ]
  292. ,
  293. "api-description" : "cgminer 4.12.0-wrk",
  294. "api-mcast-addr" : "224.0.0.75",
  295. "api-mcast-code" : "FTW",
  296. "api-mcast-des" : "",
  297. "api-mcast-port" : "4028",
  298. "api-port" : "4028",
  299. "api-host" : "0.0.0.0",
  300. "gekko-lowboost" : true,
  301. "gekko-2pac-freq" : "155.0",
  302. "gekko-compac-freq" : "150.0",
  303. "gekko-tune-down" : "95.0",
  304. "gekko-tune-up" : "97.0",
  305. "gekko-wait-factor" : "0.5",
  306. "gekko-bauddiv" : "0",
  307. "gekko-newpac-freq" : "100",
  308. "gekko-start-freq" : "100",
  309. "gekko-step-freq" : "6.2",
  310. "gekko-step-delay" : "15",
  311. "gekko-tune2" : "0",
  312. "fallback-time" : "120",
  313. "hotplug" : "5",
  314. "log" : "5",
  315. "shares" : "0",
  316. "suggest-diff" : "0"
  317. }
  318. EOF
  319. cp /tmp/cgminer.conf /home/wareck/.cgminer/
  320. echo "Done."
  321. cd /home/wareck/miners
  322. echo -e "$(tput setaf 10)\nBuild Cgminer-lketc:$(tput sgr0)"
  323. cd cgminer-lketc
  324. CFLAGS="-O2 -march=native" ./autogen.sh
  325. ./configure
  326. make -j$((`nproc`+1))
  327. cd ..
  328. echo "Done."
  329. echo -e "$(tput setaf 10)\nUncompress xmr files:$(tput sgr0)"
  330. tar xfJ /home/wareck/xmrig.tar.xz --checkpoint=.100
  331. echo "Done."
  332. echo -n -e "\n"
  333. echo -e "$(tput setaf 10)\nBuild xmrig:$(tput sgr0)"
  334. cd xmrig
  335. git config --global --add safe.directory /home/wareck/miners/xmrig
  336. git pull
  337. sed -i "s/kDefaultDonateLevel = 5;/kDefaultDonateLevel = 0;/g" src/donate.h
  338. sed -i "s/kMinimumDonateLevel = 1;/kMinimumDonateLevel = 0;/g" src/donate.h
  339. cd scripts
  340. ./build_deps.sh
  341. cd ..
  342. cd build
  343. cmake .. -DXMRIG_DEPS=scripts/deps
  344. make -j$((`nproc`))
  345. cd ..
  346. echo "Done."
  347. #echo -e "$(tput setaf 10)\nBuild xmrig-upx:$(tput sgr0)"
  348. #cd xmrig-upx
  349. #git config --global --add safe.directory /home/wareck/miners/xmrig-upx
  350. #git pull
  351. #sed -i "s/kDefaultDonateLevel = 5;/kDefaultDonateLevel = 0;/g" src/donate.h
  352. #sed -i "s/kMinimumDonateLevel = 1;/kMinimumDonateLevel = 0;/g" src/donate.h
  353. #cd build
  354. #cmake .. -DWITH_HTTPD=OFF
  355. #make -j$((`nproc`+1))
  356. #cd ..
  357. #cd ..
  358. #echo "Done."
  359. rm -r -f xmrig-upx
  360. #echo -e "$(tput setaf 10)\nBuild xmr-stak-rx:$(tput sgr0)"
  361. #cd xmr-stak-rx
  362. #git config --global --add safe.directory /home/wareck/miners/xmr-stak-rx
  363. #git pull
  364. #cd build
  365. #cmake ..
  366. #make -j$((`nproc`+1))
  367. #cd ..
  368. #cd ..
  369. #echo "Done."
  370. #echo -e "$(tput setaf 10)\nBuild xmr-stak:$(tput sgr0)"
  371. #cd xmr-stak
  372. #if ! [ -d build ];then mkdir build ;fi
  373. #git config --global --add safe.directory /home/wareck/miners/xmr-stak
  374. #git pull
  375. #cd build
  376. #cmake .. -DOpenCL_ENABLE=OFF -DCUDA_ENABLE=OFF
  377. #make -j$((`nproc`+1))
  378. #cd ..
  379. #cd ..
  380. #echo "Done."
  381. #if [ $Cuda = "YES" ]
  382. #then
  383. #echo -e "$(tput setaf 10)\nBuild xmrig-cuda:$(tput sgr0)"
  384. #git clone https://github.com/xmrig/xmrig-nvidia.git
  385. #cd xmrig-nvidia
  386. #mkdir build
  387. #cd build
  388. #cmake .. -DCMAKE_C_COMPILER=$(which gcc-8) -DCMAKE_CXX_COMPILER=$(which g++-8)
  389. #make -j$((`nproc`+1))
  390. #fi
  391. #Reduce mode
  392. if [ -d /home/wareck/miners/xmrig-upx ];then rm -r /home/wareck/miners/xmrig-upx;fi
  393. if [ -d /home/wareck/miners/xmr-stak ];then rm -r /home/wareck/miners/xmr-stak;fi
  394. if [ -d /home/wareck/miners/xmr-stak-rx ];then rm -r /home/wareck/miners/xmr-stak-rx;fi
  395. sudo chmod -R 775 /home/wareck/miners
  396. }
  397. function configure_ {
  398. echo -e "$(tput setaf 10)\nlxPanel sensors:$(tput sgr0)"
  399. cd /home/wareck
  400. if ! [ -d sensors-lxpanel-plugin ]
  401. then
  402. git clone https://github.com/danamlund/sensors-lxpanel-plugin.git
  403. fi
  404. cd /home/wareck
  405. cd sensors-lxpanel-plugin
  406. make
  407. sudo make install
  408. sudo rm -r /home/wareck/sensors-lxpanel-plugin
  409. echo "Done."
  410. echo -e "$(tput setaf 10)\nConfig files:$(tput sgr0)"
  411. cd /home/wareck/
  412. zip="['firefox.desktop', 'thunderbird.desktop', 'org.remmina.Remmina.desktop', 'filezilla.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Terminal.desktop']"
  413. cat <<'EOF'>> zap
  414. #!/bin/bash
  415. gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 32
  416. gsettings set org.gnome.desktop.background picture-uri /home/wareck/Images/mr-robot-wallpapers.jpg
  417. gsettings set org.gnome.shell favorite-apps "XXX"
  418. #su wareck -c 'gsettings set org.gnome.shell.extensions.dash-to-dock show-mounts false'
  419. dconf load /org/gnome/terminal/ < /usr/local/bin/zap2
  420. EOF
  421. sed -i "s/XXX/$zip/g" zap
  422. UUID=$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d \')
  423. cat <<'EOF'>> zap2
  424. [legacy/profiles:/:XXX]
  425. default-size-columns=110
  426. font='Monospace 9'
  427. use-system-font=false
  428. use-theme-colors=false
  429. EOF
  430. sed -i "s/XXX/$UUID/g" zap2
  431. chmod +x zap
  432. sudo cp zap /usr/local/bin
  433. sudo cp zap2 /usr/local/bin
  434. sudo rm zap
  435. sudo rm zap2
  436. sleep 1
  437. sudo rm -r -f /etc/update-motd.d/*
  438. tar xfJ pack1.tar.xz --checkpoint=.10
  439. echo -n -e "\n"
  440. sudo cp /home/wareck/pack2.tar.xz /
  441. sudo cp /home/wareck/pack3.tar.xz /
  442. cd /
  443. sudo tar xfJ pack2.tar.xz --checkpoint=.10
  444. sudo tar xfJ pack3.tar.xz --checkpoint=.10
  445. echo -n -e "\n"
  446. cd /home/wareck
  447. sudo sed -i -e "s/# set constantshow/set constantshow/g" /etc/nanorc
  448. if ! grep "wareck" /etc/sudoers >/dev/null
  449. then
  450. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  451. fi
  452. echo -e "$(tput setaf 10)\nBuild folder and mount drives:$(tput sgr0)"
  453. if ! [ -r /media/Cloud ];then sudo mkdir /media/Cloud && cd / & sudo ln -s /media/Cloud /Cloud ;fi
  454. if ! [ -r /media/Store ];then sudo mkdir /media/Store && cd / & sudo ln -s /media/Store /Store;fi
  455. if ! [ -r /media/Partage ];then sudo mkdir /media/Partage && cd / & sudo ln -s /media/Partage /Partage;fi
  456. if ! [ -r /media/Nas ];then sudo mkdir /media/Nas && cd / & sudo ln -s /media/Nas /Nas;fi
  457. if ! [ -r /raid ];then sudo mkdir /raid;fi
  458. if ! [ -r /farm ];then sudo mkdir /farm;fi
  459. if ! [ -r /farm/farm0 ];then sudo mkdir /farm/farm0;fi
  460. if ! [ -r /farm/farm1 ];then sudo mkdir /farm/farm1;fi
  461. if ! [ -r /farm/farm2 ];then sudo mkdir /farm/farm2;fi
  462. if ! [ -r /farm/farm3 ];then sudo mkdir /farm/farm3;fi
  463. if ! [ -r /farm/farm4 ];then sudo mkdir /farm/farm4;fi
  464. if ! grep "UUID=1df72b63-fca0-45c6-992c-3e2532d5591a /media/Store ext4" /etc/fstab >/dev/null
  465. then
  466. cp /etc/fstab /tmp/fstab
  467. cat <<"EOF">> /tmp/fstab
  468. #ext4
  469. UUID=6fc06d70-1a38-4706-ae83-0a329181b9f7 /media/Cloud ext4 auto,nofail,noatime,rw,user 0 0
  470. UUID=a111c12b-d1b4-441a-9352-b6bbc558184e /media/Partage ext4 auto,nofail,noatime,rw,user 0 0
  471. UUID=1df72b63-fca0-45c6-992c-3e2532d5591a /media/Store ext4 auto,nofail,noatime,rw,user 0 0
  472. #btrfs temporary drives
  473. /dev/md0 /raid btrfs ssd,nodatasum,nobarrier,nodatacow,discard=async,noatime 0 0
  474. #Chia drive
  475. UUID=77a593df-1bdb-4012-8c9e-ce50864b464d /farm/farm0 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  476. UUID=0d145a5a-50b0-456c-8998-549def2f9fc9 /farm/farm1 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  477. UUID=b99c7fa3-827c-4c09-a625-a72aec6c9395 /farm/farm2 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  478. UUID=e583a1e4-f8c8-4c2b-a427-cee854e0b56d /farm/farm3 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  479. UUID=d24c7616-91c2-434c-b21e-8dd70d794e25 /farm/farm4 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  480. EOF
  481. sudo cp /tmp/fstab /etc/fstab
  482. fi
  483. sudo rm /etc/hosts
  484. sudo cat <<'EOF'>> /etc/hosts
  485. 127.0.0.1 localhost
  486. 127.0.1.1 cube
  487. 192.168.1.8 miniserver miniserver gogserver.dnsalias.com
  488. 192.168.1.10 nzxt
  489. 192.168.1.11 garage
  490. 192.168.1.12 blade
  491. 192.168.1.254 mafreebox.freebox.fr
  492. 192.168.1.200 node
  493. # The following lines are desirable for IPv6 capable hosts
  494. ::1 ip6-localhost ip6-loopback
  495. fe00::0 ip6-localnet
  496. ff00::0 ip6-mcastprefix
  497. ff02::1 ip6-allnodes
  498. ff02::2 ip6-allrouters
  499. EOF
  500. echo "Done."
  501. echo -e "$(tput setaf 10)\nSensors drivers:$(tput sgr0)"
  502. if ! grep "it87" /etc/modules >/dev/null
  503. then
  504. cp /etc/modules /tmp/modules
  505. cat <<"EOF">> /tmp/modules
  506. # Chip drivers
  507. it87
  508. EOF
  509. sudo cp /tmp/modules /etc/modules
  510. fi
  511. if [ -f /tmp/sensors3.conf ]
  512. then
  513. chmod 777 /tmp/sensors3.conf
  514. rm /tmp/sensors3.conf
  515. fi
  516. cat <<'EOF'>> /tmp/sensors3.conf
  517. chip "it8728-isa-0228"
  518. label in0 "Vcore"
  519. label in1 "Vdram" # "DDR3" in BIOS
  520. label in2 "+3.3V"
  521. label in3 "+5V" # Not in BIOS
  522. label in4 "+12V"
  523. ignore in5 # -12V unused
  524. ignore in6
  525. label in7 "5VSB" # Not in BIOS
  526. label in8 "Vbat" # Not in BIOS
  527. compute in3 @ * (6.8/10+1), @ / (6.8/10+1)
  528. compute in4 @ * 3.963, @ / 3.963
  529. compute in7 @ * (6.8/10+1), @ / (6.8/10+1)
  530. set in0_min 0.825 * 0.95
  531. set in0_max 1.425 * 1.05
  532. set in1_min 1.5 * 0.95
  533. set in1_max 1.5 * 1.05
  534. set in2_min 3.3 * 0.95
  535. set in2_max 3.3 * 1.05
  536. set in3_min 5 * 0.95
  537. set in3_max 5 * 1.05
  538. set in4_min 12 * 0.95
  539. set in4_max 12 * 1.05
  540. set in7_min 5 * 0.95
  541. set in7_max 5 * 1.05
  542. ignore cpu0_vid
  543. set fan4_min 100
  544. set fan1_min 100
  545. ignore fan2
  546. ignore fan3
  547. ignore fan5
  548. ignore in8
  549. ignore intrusion0
  550. label fan1 "fan1"
  551. label fan4 "fan2"
  552. label temp1 "MB"
  553. label temp2 "CPU"
  554. set temp2_min 0
  555. set temp2_max 75
  556. set temp1_min 0
  557. set temp1_max 90
  558. set temp1_beep 0.0
  559. label temp1 "VRM Temp"
  560. set temp1_min 0
  561. set temp1_max 65
  562. label temp2 "SB Temp"
  563. label temp3 "CPU Temp"
  564. set temp3_min 0
  565. set temp3_max 65
  566. chip "nvme-pci-0400"
  567. set temp2_max 75
  568. set temp2_min 20
  569. set temp3_max 75
  570. set temp3_min 20
  571. EOF
  572. chmod 644 /tmp/sensors3.conf
  573. sudo cp /tmp/sensors3.conf /etc/
  574. sudo sensors -s
  575. sensors
  576. sudo apt install ethtool -y
  577. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{print $2a;getline}')
  578. sudo ethtool --change $iface wol g
  579. cat <<'EOF'>> /tmp/wakemeup.sh
  580. #!/bin/bash
  581. set -e
  582. if ! [ -x "$(command -v etherwake)" ];then sudo apt-get install etherwake -y;fi
  583. clear
  584. echo -e "$(tput setaf 10)Wake On Lan v1.0:$(tput sgr0)"
  585. PS3="Select : "
  586. items=("Nzxt" "Garage" "Blade")
  587. select item in "${items[@]}" Quit
  588. do
  589. case $REPLY in
  590. 1) sudo etherwake -i enp5s0 E0:D5:5E:2D:9E:CB ; break;;
  591. 2) sudo etherwake -i enp5s0 58:11:22:CD:FC:7A ; break;;
  592. 3) sudo etherwake -i enp5s0 78:AC:44:57:3C:50 ; break;;
  593. $((${#items[@]}+1))) echo "We're done!"; break 2;;
  594. *) echo "Ooops - unknown choice $REPLY"; break;
  595. esac
  596. done
  597. echo -e ""
  598. EOF
  599. sudo chmod +x /tmp/wakemeup.sh
  600. sudo cp /tmp/wakemeup.sh /usr/local/bin
  601. echo "Done."
  602. echo -e "$(tput setaf 10)\nVnc init:$(tput sgr0)"
  603. sudo update-rc.d vncserver defaults
  604. echo "Done."
  605. echo -e "$(tput setaf 10)\nOpening ports:$(tput sgr0)"
  606. sudo ufw allow 8333 >/dev/null
  607. sudo ufw allow 22 >/dev/null
  608. sudo ufw allow 5900 >/dev/null
  609. sudo ufw allow 10000 >/dev/null
  610. sudo ufw allow 139 >/dev/null
  611. sudo ufw allow 5901 >/dev/null
  612. sudo ufw allow 5902 >/dev/null
  613. sudo ufw allow 445 >/dev/null
  614. sudo ufw allow 1337 >/dev/null
  615. sudo ufw allow 1447 >/dev/null
  616. echo "Done."
  617. echo -e "$(tput setaf 10)\nBashrc mod:$(tput sgr0)"
  618. if [ $Cuda = "YES" ]
  619. then
  620. if ! grep "#mod for cuda" /home/wareck/.bashrc >/dev/null
  621. then
  622. echo '#mod for cuda' >>/home/wareck/.bashrc
  623. echo 'export PATH=/usr/local/cuda-12.3/bin/:$PATH'>>/home/wareck/.bashrc
  624. echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64:$LD_LIBRARY_PATH'>>/home/wareck/.bashrc
  625. echo '' >>/home/wareck/.bashrc
  626. fi
  627. fi
  628. if ! grep "#mod for tightvncserver" /home/wareck/.bashrc >/dev/null
  629. then
  630. echo '#mod for tightvncserver' >>/home/wareck/.bashrc
  631. echo 'cd ~' >>/home/wareck/.bashrc
  632. fi
  633. echo "Done."
  634. echo -e "$(tput setaf 10)\nDisable IPv6:$(tput sgr0)"
  635. if ! grep "ipv6.disable=1" /etc/default/grub >/dev/null
  636. then
  637. sed -i -e "s/quiet splash/quiet splash ipv6.disable=1/g" /etc/default/grub
  638. sed -i -e "s/GRUB_CMDLINE_LINUX=\"/GRUB_CMDLINE_LINUX=\"ipv6.disable=1 acpi_enforce_resources=lax/g" /etc/default/grub
  639. sudo update-grub2
  640. fi
  641. sudo chown -R wareck:wareck /home/wareck/miners/xmr*
  642. sudo chown -R wareck:wareck /home/wareck/miners/cgminer*
  643. sudo apt-get remove light-locker* -y
  644. if [ ! -d /home/wareck/.config/lxpanel/LXDE/panels ]
  645. then
  646. mkdir /home/wareck/.config/lxpanel
  647. mkdir /home/wareck/.config/lxpanel/LXDE
  648. mkdir /home/wareck/.config/lxpanel/LXDE/panels
  649. fi
  650. sudo cp /home/wareck/Build_Cube/pack/panel /home/wareck/.config/lxpanel/LXDE/panels/panel
  651. sudo chmod 777 /home/wareck/.config/lxpanel/LXDE/panels/panel
  652. if [ ! -d /home/wareck/.config/lxterminal ]
  653. then
  654. mkdir /home/wareck/.config/lxterminal
  655. fi
  656. sudo cp /home/wareck/Build_Cube/pack/lxterminal.conf /home/wareck/.config/lxterminal/
  657. sudo chmod 777 /home/wareck/.config/lxterminal/lxterminal.conf
  658. echo "Done."
  659. echo "passe=4" >/home/wareck/.ipass
  660. decompte_
  661. }
  662. function printer_ {
  663. if [ ! -d /usr/local/share/foomatic/ ]
  664. then
  665. if [ ! -d /tmp/foomatic-db/ ]
  666. then
  667. cd /tmp/
  668. echo -e "$(tput setaf 10)\nInstall printers generic drivers:$(tput sgr0)"
  669. git clone https://github.com/OpenPrinting/foomatic-db.git
  670. fi
  671. cd /tmp/foomatic-db
  672. if [ ! -d /usr/local/share/foomatic/ ]
  673. then
  674. ./make_configure
  675. ./configure
  676. sudo make install
  677. echo "Done."
  678. fi
  679. fi
  680. }
  681. function mounting_drives_ {
  682. echo -e "$(tput setaf 10)\nMounting Drives$(tput sgr0)"
  683. if ! findmnt /media/Partage >/dev/null ; then sudo mount /media/Partage ;fi
  684. if ! findmnt /media/Store >/dev/null ; then sudo mount /media/Store ;fi
  685. if ! findmnt /media/Cloud >/dev/null ; then sudo mount /media/Cloud ;fi
  686. sudo chmod 777 /media/Store
  687. sudo chmod 777 /media/Cloud
  688. sudo chmod 777 /media/Partage
  689. sudo chmod 777 /raid
  690. sudo chmod 777 /media/Nas
  691. echo "Done."
  692. }
  693. function cleaning_ {
  694. echo -e "$(tput setaf 10)\nCleaning install files:$(tput sgr0)"
  695. if [ -f /pack2.tar.xz ]; then sudo rm /pack2.tar.xz ;fi
  696. if [ -f /pack3.tar.xz ]; then sudo rm /pack3.tar.xz ;fi
  697. if [ -f /home/wareck/pack1.tar.xz ]; then rm /home/wareck/pack1.tar.xz ;fi
  698. if [ -f /home/wareck/pack2.tar.xz ]; then rm /home/wareck/pack2.tar.xz ;fi
  699. if [ -f /home/wareck/pack3.tar.xz ]; then rm /home/wareck/pack3.tar.xz ;fi
  700. if [ -f /home/wareck/xmrig.tar.xz ]; then rm /home/wareck/xmrig.tar.xz ;fi
  701. if [ -f /home/wareck/gpu-miners.tar.xz ]; then rm /home/wareck/gpu-miners.tar.xz;fi
  702. if [ -r /home/wareck/Music ]; then sudo rm -r -f /home/wareck/Music ;fi
  703. if [ -r /home/wareck/Public ]; then sudo rm -r -f /home/wareck/Public ;fi
  704. if [ -r /home/wareck/Templates ]; then sudo rm -r -f /home/wareck/Templates ;fi
  705. if [ -r /home/wareck/Vidéos ]; then sudo rm -r -f /home/wareck/Vidéos ;fi
  706. if [ -f /home/wareck/NVIDIA-Linux-x86_64-470.74.run ]; then rm /home/wareck/NVIDIA-Linux-x86_64-470.74.run ;fi
  707. if [ -f /home/wareck/NVIDIA-Linux-x86_64-470.82.00.run ]; then rm /home/wareck/NVIDIA-Linux-x86_64-470.82.00.run ;fi
  708. if [ -f /home/wareck/.ipass ]; then rm /home/wareck/.ipass ;fi
  709. if [ -f /usr/local/bin/zap ]; then sudo rm /usr/local/bin/zap* ;fi
  710. if [ -f /home/wareck/.config/autostart/install_os.desktop ];then sudo rm /home/wareck/.config/autostart/install_os.desktop;fi
  711. if [ -f /home/wareck/.config/autostart/zappy.desktop ];then sudo rm /home/wareck/.config/autostart/zappy.desktop;fi
  712. if [ -r /lib/modules/5.15.0-60-generic ]; then sudo rm -r /lib/modules/5.15.0-60-generic ;fi
  713. if [ -r /lib/modules/5.15.0-46-generic ]; then sudo rm -r /lib/modules/5.15.0-46-generic ;fi
  714. if [ -r /lib/modules/5.15.0-70-generic ]; then sudo rm -r /lib/modules/5.15.0-70-generic ;fi
  715. cd /home/wareck/Build_Cube/pack
  716. sudo chown -R wareck:wareck /home/wareck/miners
  717. sudo chmod -R 775 /home/wareck/miners
  718. ./clean.sh
  719. echo -e "Done. \n"
  720. echo `date` "install/update" >/home/wareck/.buildcube
  721. sudo apt-get autoremove -y
  722. sleep 1
  723. }
  724. function autoroot_ {
  725. if ! grep "#color putty" ~/.bashrc >/dev/null
  726. then
  727. echo "#color putty" >> ~/.bashrc
  728. echo "export TERM=xterm-256color" >> ~/.bashrc
  729. fi
  730. if [ ! -d /home/wareck/.config/autostart ]
  731. then
  732. echo -e "$(tput setaf 10)\nInit install & autostart:$(tput sgr0)"
  733. mkdir /home/wareck/.config/autostart
  734. echo -e "Done."
  735. sleep 1
  736. fi
  737. if [ ! -f /home/wareck/.config/autostart/install_os.desktop ]
  738. then
  739. cat <<'EOF'>> /home/wareck/.config/autostart/install_os.desktop
  740. [Desktop Entry]
  741. # VERSION=3.36.2
  742. Name=Terminal
  743. Comment=Use the command line
  744. Keywords=shell;prompt;command;commandline;cmd;
  745. TryExec=gnome-terminal
  746. Exec=gnome-terminal -- bash -c "sudo /home/wareck/Build_Cube/build_cube.sh; exec bash"
  747. Icon=org.gnome.Terminal
  748. Type=Application
  749. Categories=GNOME;GTK;System;TerminalEmulator;
  750. StartupNotify=true
  751. X-GNOME-SingleWindow=false
  752. OnlyShowIn=GNOME;Unity;
  753. Actions=new-window;preferences;
  754. X-Ubuntu-Gettext-Domain=gnome-terminal
  755. [Desktop Action new-window]
  756. Name=New Window
  757. Exec=gnome-terminal --window
  758. [Desktop Action preferences]
  759. Name=Preferences
  760. Exec=gnome-terminal --preferences
  761. EOF
  762. chmod +x /home/wareck/.config/autostart/install_os.desktop
  763. fi
  764. if [ ! -f /home/wareck/.config/autostart/zappy.desktop ]
  765. then
  766. cat <<'EOF'>> /home/wareck/.config/autostart/zappy.desktop
  767. [Desktop Entry]
  768. # VERSION=3.36.2
  769. Name=Terminal
  770. Comment=Use the command line
  771. Keywords=shell;prompt;command;commandline;cmd;
  772. TryExec=gnome-terminal
  773. Exec=gnome-terminal -- bash -c "/usr/local/bin/zap"
  774. Icon=org.gnome.Terminal
  775. Type=Application
  776. Categories=GNOME;GTK;System;TerminalEmulator;
  777. StartupNotify=true
  778. X-GNOME-SingleWindow=false
  779. OnlyShowIn=GNOME;Unity;
  780. Actions=new-window;preferences;
  781. X-Ubuntu-Gettext-Domain=gnome-terminal
  782. [Desktop Action new-window]
  783. Name=New Window
  784. Exec=gnome-terminal --window
  785. [Desktop Action preferences]
  786. Name=Preferences
  787. Exec=gnome-terminal --preferences
  788. EOF
  789. chmod +x /home/wareck/.config/autostart/zappy.desktop
  790. fi
  791. if ! grep "wareck" /etc/sudoers >/dev/null
  792. then
  793. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  794. fi
  795. if [ $passe="2" ]
  796. then
  797. echo -e "$(tput setaf 10)\nUpdate and install packages:$(tput sgr0)"
  798. sudo apt-get update
  799. sudo apt-get install lxde lxde-icon-theme -y
  800. sleep 1
  801. fi
  802. }
  803. function remove_screensaver {
  804. #remove screensaver
  805. cat <<EOF>> autostart
  806. @lxpanel --profile LXDE
  807. @pcmanfm --desktop --profile LXDE
  808. EOF
  809. sudo chmod 744 autostart
  810. sudo cp autostart /etc/xdg/lxsession/LXDE/
  811. sudo cp autostart /home/wareck/.config/lxsession/LXDE/
  812. sudo rm autostart
  813. sudo apt-get remove xscreensaver xscreensaver-data -y
  814. }
  815. function cmake_ {
  816. pids=""
  817. /home/wareck/Build_Cube/options/tools/_cmake.sh rollback & pids="$pids $!"
  818. wait $pids
  819. sudo ldconfig
  820. }
  821. function watchdog_ {
  822. pids=""
  823. /home/wareck/Build_Cube/options/watchdog.sh ext & pids="$pids $!"
  824. wait $pids
  825. }
  826. function wol_ {
  827. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{print $2a;getline}')
  828. ether=$(which ethtool)
  829. echo "[Unit]" >>/tmp/wol.service
  830. echo "Description=Enable Wake On Lan" >>/tmp/wol.service
  831. echo "" >>/tmp/wol.service
  832. echo "[Service]" >>/tmp/wol.service
  833. echo "Type=oneshot" >>/tmp/wol.service
  834. echo "ExecStart = $ether --change$iface wol g" >>/tmp/wol.service
  835. echo "" >>/tmp/wol.service
  836. echo "[Install]" >>/tmp/wol.service
  837. echo "WantedBy=basic.target" >>/tmp/wol.service
  838. sudo cp /tmp/wol.service /etc/systemd/system/wol.service
  839. sudo systemctl daemon-reload >/dev/null
  840. sudo systemctl enable wol.service >/dev/null
  841. sudo systemctl start wol.service >/dev/null
  842. sleep 2
  843. clear
  844. }
  845. intro_
  846. case $passe in
  847. 1)
  848. watchdog_
  849. autoroot_
  850. ubuntu_version_check
  851. update_
  852. kernel_check_
  853. nvidia_driver_
  854. ;;
  855. 2)
  856. nvidia_driver_
  857. update_
  858. ;;
  859. 3)
  860. download_packs_
  861. printer_
  862. build_miners_
  863. configure_
  864. ;;
  865. 4)
  866. mounting_drives_
  867. cleaning_
  868. remove_screensaver
  869. clear
  870. wol_
  871. dynmotd
  872. ;;
  873. *) ;;
  874. esac
  875. echo -e "$(tput setaf 10)\nEnd of script:$(tput sgr0) \n"
  876. echo -e "$(tput setaf 7)Need to install webmin manually (reboot required)$(tput sgr0)"
  877. echo -e "$(tput setaf 7)after install webmin, reboot is required $(tput sgr0)"
  878. echo -e ""