build_cube.sh 27 KB

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