build_cube.sh 27 KB

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