build_cube.sh 28 KB

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