build_cube.sh 27 KB

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