build_cube.sh 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. #!/bin/bash
  2. set -e
  3. Version=14.7
  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. 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/nvme0 ];then sudo mkdir /media/nvme0 && cd / & sudo ln -s /media/nvme0 /nvme0 ;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 ! [ -r /farm/farm4 ];then sudo mkdir /farm/farm4;fi
  465. if ! grep "UUID=1df72b63-fca0-45c6-992c-3e2532d5591a /media/Store ext4" /etc/fstab >/dev/null
  466. then
  467. cp /etc/fstab /tmp/fstab
  468. cat <<"EOF">> /tmp/fstab
  469. #ext4
  470. UUID=6fc06d70-1a38-4706-ae83-0a329181b9f7 /media/Cloud 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. UUID=1df72b63-fca0-45c6-992c-3e2532d5591a /media/Store ext4 auto,nofail,noatime,rw,user 0 0
  473. #btrfs temporary drives
  474. UUID=12094228-c990-4fe7-a6d2-bc8fcb83df32 /nvme0 btrfs ssd,nodatasum,nobarrier,nodatacow,discard=async,noatime
  475. UUID=c6f4973e-a576-44d3-b9f7-9b667f3b97c6 /nvme1 btrfs ssd,nodatasum,nobarrier,nodatacow,discard=async,noatime
  476. #Chia drive
  477. UUID=77a593df-1bdb-4012-8c9e-ce50864b464d /farm/farm0 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  478. UUID=0d145a5a-50b0-456c-8998-549def2f9fc9 /farm/farm1 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  479. UUID=b99c7fa3-827c-4c09-a625-a72aec6c9395 /farm/farm2 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  480. UUID=e583a1e4-f8c8-4c2b-a427-cee854e0b56d /farm/farm3 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  481. UUID=9f0be851-ce3e-4be6-a374-087b44981cb6 /farm/farm4 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  482. EOF
  483. sudo cp /tmp/fstab /etc/fstab
  484. fi
  485. sudo rm /etc/hosts
  486. sudo cat <<'EOF'>> /etc/hosts
  487. 127.0.0.1 localhost
  488. 127.0.1.1 cube
  489. 192.168.1.8 miniserver miniserver gogserver.dnsalias.com
  490. 192.168.1.10 nzxt
  491. 192.168.1.11 garage
  492. 192.168.1.254 mafreebox.freebox.fr
  493. 192.168.1.200 node
  494. # The following lines are desirable for IPv6 capable hosts
  495. ::1 ip6-localhost ip6-loopback
  496. fe00::0 ip6-localnet
  497. ff00::0 ip6-mcastprefix
  498. ff02::1 ip6-allnodes
  499. ff02::2 ip6-allrouters
  500. EOF
  501. echo "Done."
  502. echo -e "$(tput setaf 10)\nSensors drivers:$(tput sgr0)"
  503. if ! grep "it87" /etc/modules >/dev/null
  504. then
  505. cp /etc/modules /tmp/modules
  506. cat <<"EOF">> /tmp/modules
  507. # Chip drivers
  508. it87
  509. EOF
  510. sudo cp /tmp/modules /etc/modules
  511. fi
  512. if [ -f /tmp/sensors3.conf ]
  513. then
  514. chmod 777 /tmp/sensors3.conf
  515. rm /tmp/sensors3.conf
  516. fi
  517. cat <<'EOF'>> /tmp/sensors3.conf
  518. chip "it8728-isa-0228"
  519. label in0 "Vcore"
  520. label in1 "Vdram" # "DDR3" in BIOS
  521. label in2 "+3.3V"
  522. label in3 "+5V" # Not in BIOS
  523. label in4 "+12V"
  524. ignore in5 # -12V unused
  525. ignore in6
  526. label in7 "5VSB" # Not in BIOS
  527. label in8 "Vbat" # Not in BIOS
  528. compute in3 @ * (6.8/10+1), @ / (6.8/10+1)
  529. compute in4 @ * 3.963, @ / 3.963
  530. compute in7 @ * (6.8/10+1), @ / (6.8/10+1)
  531. set in0_min 0.825 * 0.95
  532. set in0_max 1.425 * 1.05
  533. set in1_min 1.5 * 0.95
  534. set in1_max 1.5 * 1.05
  535. set in2_min 3.3 * 0.95
  536. set in2_max 3.3 * 1.05
  537. set in3_min 5 * 0.95
  538. set in3_max 5 * 1.05
  539. set in4_min 12 * 0.95
  540. set in4_max 12 * 1.05
  541. set in7_min 5 * 0.95
  542. set in7_max 5 * 1.05
  543. ignore cpu0_vid
  544. set fan4_min 100
  545. set fan1_min 100
  546. ignore fan2
  547. ignore fan3
  548. ignore fan5
  549. ignore in8
  550. ignore intrusion0
  551. label fan1 "fan1"
  552. label fan4 "fan2"
  553. label temp1 "MB"
  554. label temp2 "CPU"
  555. set temp2_min 0
  556. set temp2_max 75
  557. set temp1_min 0
  558. set temp1_max 90
  559. set temp1_beep 0.0
  560. label temp1 "VRM Temp"
  561. set temp1_min 0
  562. set temp1_max 65
  563. label temp2 "SB Temp"
  564. label temp3 "CPU Temp"
  565. set temp3_min 0
  566. set temp3_max 65
  567. chip "nvme-pci-0400"
  568. set temp2_max 75
  569. set temp2_min 20
  570. set temp3_max 75
  571. set temp3_min 20
  572. EOF
  573. chmod 644 /tmp/sensors3.conf
  574. sudo cp /tmp/sensors3.conf /etc/
  575. sudo sensors -s
  576. sensors
  577. sudo apt install ethtool -y
  578. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{print $2a;getline}')
  579. sudo ethtool --change $iface wol g
  580. cat <<'EOF'>> /tmp/wakemeup.sh
  581. #!/bin/bash
  582. set -e
  583. if ! [ -x "$(command -v etherwake)" ];then sudo apt-get install etherwake -y;fi
  584. clear
  585. echo -e "$(tput setaf 10)Wake On Lan v1.0:$(tput sgr0)"
  586. PS3="Select : "
  587. items=("Nzxt" "Garage")
  588. select item in "${items[@]}" Quit
  589. do
  590. case $REPLY in
  591. 1) sudo etherwake -i enp5s0 58:11:22:CD:FC:7A ; break;;
  592. 2) sudo etherwake -i enp5s0 E0:D5:5E:2D:9E:CB ; break;;
  593. $((${#items[@]}+1))) echo "We're done!"; break 2;;
  594. *) echo "Ooops - unknown choice $REPLY"; break;
  595. esac
  596. done
  597. echo -e ""
  598. EOF
  599. sudo chmod +x /tmp/wakemeup.sh
  600. sudo cp /tmp/wakemeup.sh /usr/local/bin
  601. echo "Done."
  602. echo -e "$(tput setaf 10)\nVnc init:$(tput sgr0)"
  603. sudo update-rc.d vncserver defaults
  604. echo "Done."
  605. echo -e "$(tput setaf 10)\nOpening ports:$(tput sgr0)"
  606. sudo ufw allow 8333 >/dev/null
  607. sudo ufw allow 22 >/dev/null
  608. sudo ufw allow 5900 >/dev/null
  609. sudo ufw allow 10000 >/dev/null
  610. sudo ufw allow 139 >/dev/null
  611. sudo ufw allow 5901 >/dev/null
  612. sudo ufw allow 5902 >/dev/null
  613. sudo ufw allow 445 >/dev/null
  614. echo "Done."
  615. echo -e "$(tput setaf 10)\nBashrc mod:$(tput sgr0)"
  616. if ! grep "#mod for tightvncserver" /home/wareck/.bashrc
  617. then
  618. echo "#mod for tightvncserver" >>/home/wareck/.bashrc
  619. echo "cd ~" >>/home/wareck/.bashrc
  620. fi
  621. echo "Done."
  622. echo -e "$(tput setaf 10)\nDisable IPv6:$(tput sgr0)"
  623. if ! grep "ipv6.disable=1" /etc/default/grub >/dev/null
  624. then
  625. sed -i -e "s/quiet splash/quiet splash ipv6.disable=1/g" /etc/default/grub
  626. sed -i -e "s/GRUB_CMDLINE_LINUX=\"/GRUB_CMDLINE_LINUX=\"ipv6.disable=1 acpi_enforce_resources=lax/g" /etc/default/grub
  627. sudo update-grub2
  628. fi
  629. sudo chown -R wareck:wareck /home/wareck/miners/xmr*
  630. sudo chown -R wareck:wareck /home/wareck/miners/cgminer*
  631. sudo apt-get remove light-locker* -y
  632. if [ ! -d /home/wareck/.config/lxpanel/LXDE/panels ]
  633. then
  634. mkdir /home/wareck/.config/lxpanel
  635. mkdir /home/wareck/.config/lxpanel/LXDE
  636. mkdir /home/wareck/.config/lxpanel/LXDE/panels
  637. fi
  638. sudo cp /home/wareck/Build_Cube/pack/panel /home/wareck/.config/lxpanel/LXDE/panels/panel
  639. sudo chmod 777 /home/wareck/.config/lxpanel/LXDE/panels/panel
  640. if [ ! -d /home/wareck/.config/lxterminal ]
  641. then
  642. mkdir /home/wareck/.config/lxterminal
  643. fi
  644. sudo cp /home/wareck/Build_Cube/pack/lxterminal.conf /home/wareck/.config/lxterminal/
  645. sudo chmod 777 /home/wareck/.config/lxterminal/lxterminal.conf
  646. echo "Done."
  647. touch /home/wareck/.pass4
  648. decompte_
  649. fi
  650. }
  651. function printer_ {
  652. if [ ! -f /home/wareck/.pass3 ]
  653. then
  654. if [ ! -d /usr/local/share/foomatic/ ]
  655. then
  656. if [ ! -d /tmp/foomatic-db/ ]
  657. then
  658. cd /tmp/
  659. echo -e "$(tput setaf 10)\nInstall printers generic drivers:$(tput sgr0)"
  660. git clone https://github.com/OpenPrinting/foomatic-db.git
  661. fi
  662. cd /tmp/foomatic-db
  663. if [ ! -d /usr/local/share/foomatic/ ]
  664. then
  665. ./make_configure
  666. ./configure
  667. sudo make install
  668. echo "Done."
  669. fi
  670. fi
  671. fi
  672. }
  673. function mounting_drives_ {
  674. if [ ! -f /home/wareck/.pass4 ]
  675. then
  676. echo -e "$(tput setaf 10)\nMounting Drives$(tput sgr0)"
  677. if ! findmnt /media/Partage >/dev/null ; then sudo mount /media/Partage ;fi
  678. if ! findmnt /media/Store >/dev/null ; then sudo mount /media/Store ;fi
  679. if ! findmnt /media/Cloud >/dev/null ; then sudo mount /media/Cloud ;fi
  680. sudo chmod 777 /media/Store
  681. sudo chmod 777 /media/Cloud
  682. sudo chmod 777 /media/Partage
  683. sudo chmod 777 /media/nvme0
  684. sudo chmod 777 /media/nvme1
  685. sudo chmod 777 /media/Nas
  686. echo "Done."
  687. fi
  688. }
  689. function cleaning_ {
  690. if [ -f /home/wareck/.pass4 ]
  691. then
  692. echo -e "$(tput setaf 10)\nCleaning install files:$(tput sgr0)"
  693. if [ -f /pack2.tar.xz ]; then sudo rm /pack2.tar.xz ;fi
  694. if [ -f /pack3.tar.xz ]; then sudo rm /pack3.tar.xz ;fi
  695. if [ -f /home/wareck/pack1.tar.xz ]; then rm /home/wareck/pack1.tar.xz ;fi
  696. if [ -f /home/wareck/pack2.tar.xz ]; then rm /home/wareck/pack2.tar.xz ;fi
  697. if [ -f /home/wareck/pack3.tar.xz ]; then rm /home/wareck/pack3.tar.xz ;fi
  698. if [ -f /home/wareck/xmrig.tar.xz ]; then rm /home/wareck/xmrig.tar.xz ;fi
  699. if [ -f /home/wareck/gpu-miners.tar.xz ]; then rm /home/wareck/gpu-miners.tar.xz;fi
  700. if [ -r /home/wareck/Music ]; then sudo rm -r -f /home/wareck/Music ;fi
  701. if [ -r /home/wareck/Public ]; then sudo rm -r -f /home/wareck/Public ;fi
  702. if [ -r /home/wareck/Templates ]; then sudo rm -r -f /home/wareck/Templates ;fi
  703. if [ -r /home/wareck/Vidéos ]; then sudo rm -r -f /home/wareck/Vidéos ;fi
  704. if [ -f /home/wareck/NVIDIA-Linux-x86_64-470.74.run ]; then rm /home/wareck/NVIDIA-Linux-x86_64-470.74.run ;fi
  705. 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
  706. if [ -f /home/wareck/.pass1 ]; then rm /home/wareck/.pass1 ;fi
  707. if [ -f /home/wareck/.pass2 ]; then rm /home/wareck/.pass2 ;fi
  708. if [ -f /home/wareck/.pass3 ]; then rm /home/wareck/.pass3 ;fi
  709. if [ -f /home/wareck/.pass4 ]; then rm /home/wareck/.pass4 ;fi
  710. if [ -f /usr/local/bin/zap ]; then sudo rm /usr/local/bin/zap* ;fi
  711. if [ -f /home/wareck/.config/autostart/install_os.desktop ];then sudo rm /home/wareck/.config/autostart/install_os.desktop;fi
  712. if [ -f /home/wareck/.config/autostart/zappy.desktop ];then sudo rm /home/wareck/.config/autostart/zappy.desktop;fi
  713. if [ -r /lib/modules/5.15.0-60-generic ]; then sudo rm -r /lib/modules/5.15.0-60-generic ;fi
  714. if [ -r /lib/modules/5.15.0-46-generic ]; then sudo rm -r /lib/modules/5.15.0-46-generic ;fi
  715. if [ -r /lib/modules/5.15.0-70-generic ]; then sudo rm -r /lib/modules/5.15.0-70-generic ;fi
  716. cd /home/wareck/Build_Cube/pack
  717. sudo chown -R wareck:wareck /home/wareck/miners
  718. sudo chmod -R 775 /home/wareck/miners
  719. ./clean.sh
  720. echo -e "Done. \n"
  721. echo `date` "install/update" >/home/wareck/.buildcube
  722. fi
  723. sudo apt-get autoremove -y
  724. sleep 1
  725. }
  726. function autoroot_ {
  727. if [ ! -d /home/wareck/.config/autostart ]
  728. then
  729. echo -e "$(tput setaf 10)\nInit install & autostart:$(tput sgr0)"
  730. mkdir /home/wareck/.config/autostart
  731. echo -e "Done."
  732. fi
  733. if [ ! -f /home/wareck/.config/autostart/install_os.desktop ]
  734. then
  735. cat <<'EOF'>> /home/wareck/.config/autostart/install_os.desktop
  736. [Desktop Entry]
  737. # VERSION=3.36.2
  738. Name=Terminal
  739. Comment=Use the command line
  740. Keywords=shell;prompt;command;commandline;cmd;
  741. TryExec=gnome-terminal
  742. Exec=gnome-terminal -- bash -c "sudo /home/wareck/Build_Cube/build_cube.sh; exec bash"
  743. Icon=org.gnome.Terminal
  744. Type=Application
  745. Categories=GNOME;GTK;System;TerminalEmulator;
  746. StartupNotify=true
  747. X-GNOME-SingleWindow=false
  748. OnlyShowIn=GNOME;Unity;
  749. Actions=new-window;preferences;
  750. X-Ubuntu-Gettext-Domain=gnome-terminal
  751. [Desktop Action new-window]
  752. Name=New Window
  753. Exec=gnome-terminal --window
  754. [Desktop Action preferences]
  755. Name=Preferences
  756. Exec=gnome-terminal --preferences
  757. EOF
  758. chmod +x /home/wareck/.config/autostart/install_os.desktop
  759. fi
  760. if [ ! -f /home/wareck/.config/autostart/zappy.desktop ]
  761. then
  762. cat <<'EOF'>> /home/wareck/.config/autostart/zappy.desktop
  763. [Desktop Entry]
  764. # VERSION=3.36.2
  765. Name=Terminal
  766. Comment=Use the command line
  767. Keywords=shell;prompt;command;commandline;cmd;
  768. TryExec=gnome-terminal
  769. Exec=gnome-terminal -- bash -c "/usr/local/bin/zap"
  770. Icon=org.gnome.Terminal
  771. Type=Application
  772. Categories=GNOME;GTK;System;TerminalEmulator;
  773. StartupNotify=true
  774. X-GNOME-SingleWindow=false
  775. OnlyShowIn=GNOME;Unity;
  776. Actions=new-window;preferences;
  777. X-Ubuntu-Gettext-Domain=gnome-terminal
  778. [Desktop Action new-window]
  779. Name=New Window
  780. Exec=gnome-terminal --window
  781. [Desktop Action preferences]
  782. Name=Preferences
  783. Exec=gnome-terminal --preferences
  784. EOF
  785. chmod +x /home/wareck/.config/autostart/zappy.desktop
  786. fi
  787. if ! grep "wareck" /etc/sudoers >/dev/null
  788. then
  789. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  790. fi
  791. }
  792. function remove_screensaver {
  793. #remove screensaver
  794. cat <<EOF>> autostart
  795. @lxpanel --profile LXDE
  796. @pcmanfm --desktop --profile LXDE
  797. EOF
  798. sudo chmod 744 autostart
  799. sudo cp autostart /etc/xdg/lxsession/LXDE/
  800. sudo cp autostart /home/wareck/.config/lxsession/LXDE/
  801. sudo rm autostart
  802. sudo apt-get remove xscreensaver xscreensaver-data -y
  803. }
  804. intro_
  805. autoroot_
  806. ubuntu_version_check
  807. update_
  808. kernel_check_
  809. autoroot_
  810. nvidia_driver_
  811. update_
  812. download_packs_
  813. printer_
  814. build_miners_
  815. configure_
  816. mounting_drives_
  817. cleaning_
  818. remove_screensaver
  819. clear
  820. dynmotd
  821. echo -e "$(tput setaf 10)\nEnd of script:$(tput sgr0) \n"
  822. echo -e "$(tput setaf 7)Need to install webmin manually (reboot required)$(tput sgr0)"
  823. echo -e "$(tput setaf 7)after install webmin, reboot is required $(tput sgr0)"
  824. echo -e ""