build_cube.sh 29 KB

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