build_cube.sh 29 KB

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