jupiter.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. #!/bin/bash
  2. set -e
  3. Version=18.4.2
  4. Cuda=YES
  5. kernel_custom=YES
  6. Miners=Yes
  7. driver=NVIDIA
  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. if [ ! -f /home/wareck/.ipass ]
  14. then
  15. echo "passe=1" > /home/wareck/.ipass
  16. fi
  17. source /home/wareck/.ipass
  18. export TERM=xterm-256color
  19. Cuda=${Cuda^^}
  20. kernel_custom=${kernel_custom^^}
  21. driver=${driver^^}
  22. Miners=${Miners^^}
  23. cpass=""
  24. function ubuntu_version_check {
  25. if [[ $(lsb_release -rs) == "20.04" ]]
  26. then
  27. Ubuntu_version="20.04.6"
  28. else
  29. echo "Non-compatible version !"
  30. exit 0
  31. fi
  32. }
  33. function print_centered {
  34. [[ $# == 0 ]] && return 1
  35. declare -i TERM_COLS="$(tput cols)"
  36. declare -i str_len="${#1}"
  37. [[ $str_len -ge $TERM_COLS ]] && {
  38. echo "$1";
  39. return 0;
  40. }
  41. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  42. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  43. filler=""
  44. for (( i = 0; i < filler_len; i++ )); do
  45. filler="${filler}${ch}"
  46. done
  47. printf "%s%s%s" "$filler" "$1" "$filler"
  48. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  49. printf "\n"
  50. return 0
  51. }
  52. function decompte_ {
  53. echo -e "$(tput setaf 10)\nReboot in 10 seconds (CRTL+C to abord):$(tput sgr0)"
  54. for i in {9..0}
  55. do
  56. echo -e -n "$i "
  57. sleep 1
  58. done
  59. echo ""
  60. sudo reboot
  61. }
  62. function intro_ {
  63. print_centered "$(tput setaf 1)"
  64. print_centered " ██╗██╗ ██╗██████╗ ██╗████████╗███████╗██████╗ "
  65. print_centered " ██║██║ ██║██╔══██╗██║╚══██╔══╝██╔════╝██╔══██╗"
  66. print_centered " ██║██║ ██║██████╔╝██║ ██║ █████╗ ██████╔╝"
  67. print_centered "██ ██║██║ ██║██╔═══╝ ██║ ██║ ██╔══╝ ██╔══██╗"
  68. print_centered "╚█████╔╝╚██████╔╝██║ ██║ ██║ ███████╗██║ ██║"
  69. print_centered " ╚════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝"
  70. print_centered " "
  71. echo -n "$(tput sgr0)"
  72. print_centered "Edge Server script v$Version"
  73. print_centered "Ubuntu version 20.04.6"
  74. if [ $Cuda = "YES" ]
  75. then
  76. print_centered "CUDA Compute Drivers"
  77. fi
  78. print_centered "Stage $passe/4"
  79. }
  80. function update_ {
  81. case $passe in
  82. 1)
  83. echo -e "$(tput setaf 10)\nUpdate and install packages (second pass):$(tput sgr0)"
  84. sudo apt-get update
  85. echo -e ""
  86. sudo apt-get install cifs-utils mdadm git build-essential libtool pkg-config automake autoconf ethtool net-tools \
  87. tasksel lzma-dev lzma cmake libuv1-dev libssl-dev openssh-server xfsprogs -y
  88. echo -e ""
  89. sudo apt-get install zstd pixz pbzip2 pigz btrfs-progs gparted gpart gnome-remote-desktop libcanberra-gtk-module \
  90. bison byacc screen curl nvme-cli -y
  91. echo -e ""
  92. sudo apt-get install libglib2.0-dev locate cmake -y
  93. echo -e "Done."
  94. ;;
  95. 2)
  96. if [ $Cuda = "YES" ]
  97. then
  98. echo -e "$(tput setaf 10)\nInstall Cuda packages:$(tput sgr0)"
  99. sudo apt-get install libgmp-dev libnuma-dev cmake libuv1-dev nvidia-cuda-dev libmicrohttpd-dev gcc-8 g++-8 nvidia-cuda-toolkit -y
  100. fi
  101. echo -e "Done.\n"
  102. ;;
  103. esac
  104. }
  105. function kernel_check_ {
  106. unamestr=$(uname -r)
  107. if ! [[ "$unamestr" == "5.15.159-jupiter" ]]
  108. then
  109. echo -e "\n$(tput setaf 10)Custom kernel install $(tput setaf 9)5.15.159-custom(tput setaf 10) (fix DKMS/WOL) :$(tput sgr0)"
  110. cd /tmp/
  111. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/custom_kernel/kernel_5.15.159-jupiter.run
  112. chmod +x kernel_5.15.159-jupiter.run
  113. sudo ./kernel_5.15.159-jupiter.run
  114. if ! [ -f /etc/modprobe.d/blacklist-nvidia-nouveau.conf ]
  115. then
  116. echo "Blacklist nvidia-nouveau driver..."
  117. echo "System will reboot"
  118. sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
  119. sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
  120. fi
  121. fi
  122. }
  123. function nvidia_driver_ {
  124. if [ $passe = "1" ]
  125. then
  126. if ! [ -f /etc/modprobe.d/blacklist-nvidia-nouveau.conf ]
  127. then
  128. echo "Blacklist nvidia-nouveau driver..."
  129. echo "System will reboot"
  130. sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
  131. sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
  132. fi
  133. if [ $Cuda = "NO" ]
  134. then
  135. sudo apt-get install build-essential libglvnd-dev cmake -y
  136. else
  137. sudo apt-get install build-essential libglvnd-dev cmake libhugetlbfs-dev libc-dev libc6-dev g++ -y
  138. fi
  139. echo "passe=2" > /home/wareck/.ipass
  140. decompte_
  141. fi
  142. if [ $passe = "2" ]
  143. then
  144. case $Cuda in
  145. NO)
  146. echo -e "$(tput setaf 10)\nInstall NVIDIA GTX1080 Drivers :$(tput sgr0)"
  147. sleep 3
  148. sudo apt-get install nvidia-driver-525 -y
  149. touch /home/wareck/.pass2
  150. decompte_
  151. ;;
  152. YES)
  153. echo -e "$(tput setaf 10)\nInstall CUDA Drivers :$(tput sgr0)"
  154. cd /home/wareck/
  155. echo -e "Download MegaDownload:"
  156. git clone https://github.com/wareck/megadown.git
  157. sudo cp /home/wareck/megadown/megadown /usr/local/bin/megadown
  158. sudo rm -r /home/wareck/megadown
  159. wget -c https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda_12.4.1_550.54.15_linux.run
  160. chmod +x cuda_12.4.1_550.54.15_linux.run
  161. sudo ./cuda_12.4.1_550.54.15_linux.run --silent --driver --toolkit
  162. sudo rm cuda_12.4.1_550.54.15_linux.run
  163. echo "passe=3" > /home/wareck/.ipass
  164. decompte_
  165. ;;
  166. esac
  167. fi
  168. }
  169. function download_packs_ {
  170. echo -e "$(tput setaf 10)\nDownload complement packs:$(tput sgr0)"
  171. 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
  172. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/$Webmin.tar.xz -O /home/wareck/Build_Cube/pack/$Webmin.tar.xz
  173. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/xmrig.tar.xz -O /home/wareck/Build_Cube/pack/xmrig.tar.xz
  174. 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
  175. cp /home/wareck/Build_Cube/pack/gpu-miners.tar.xz /home/wareck
  176. cp /home/wareck/Build_Cube/pack/pack1.tar.xz /home/wareck
  177. cp /home/wareck/Build_Cube/pack/pack2.tar.xz /home/wareck
  178. cp /home/wareck/Build_Cube/pack/pack3.tar.xz /home/wareck
  179. cp /home/wareck/Build_Cube/pack/xmrig.tar.xz /home/wareck
  180. echo -e "Done."
  181. if [ ! -d /home/wareck/$Webmin ]
  182. then
  183. cp /home/wareck/Build_Cube/pack/$Webmin.tar.xz /home/wareck/
  184. cd /home/wareck/
  185. echo -e "$(tput setaf 10)\nWebmin uncompress:$(tput sgr0)"
  186. tar xfJ $Webmin.tar.xz
  187. rm $Webmin.tar.xz
  188. echo -e "Done"
  189. fi
  190. echo -e "$(tput setaf 10)\nDownloading miners:$(tput sgr0)"
  191. cd /home/wareck
  192. if ! [ -d miners ]; then mkdir -p miners;fi
  193. cd /home/wareck/miners
  194. if ! [ -d xmrig ]
  195. then
  196. git clone https://github.com/xmrig/xmrig.git
  197. echo -e ""
  198. fi
  199. echo -e "Done.\n"
  200. }
  201. function build_miners_ {
  202. cmake_ #check cmake version
  203. cd /home/wareck
  204. tar xfJ gpu-miners.tar.xz
  205. cd /home/wareck/miners
  206. echo -e "$(tput setaf 10)\nUncompress xmr files:$(tput sgr0)"
  207. tar xfJ /home/wareck/xmrig.tar.xz --checkpoint=.100
  208. echo "Done."
  209. echo -n -e "\n"
  210. echo -e "$(tput setaf 10)\nBuild xmrig:$(tput sgr0)"
  211. cd xmrig
  212. git config --global --add safe.directory /home/wareck/miners/xmrig
  213. git pull
  214. sed -i "s/kDefaultDonateLevel = 5;/kDefaultDonateLevel = 0;/g" src/donate.h
  215. sed -i "s/kMinimumDonateLevel = 1;/kMinimumDonateLevel = 0;/g" src/donate.h
  216. cd scripts
  217. ./build_deps.sh
  218. cd ..
  219. cd build
  220. cmake .. -DXMRIG_DEPS=scripts/deps
  221. make -j$((`nproc`))
  222. cd ..
  223. echo "Done."
  224. #Reduce mode
  225. if [ -d /home/wareck/miners/xmrig-upx ];then rm -r /home/wareck/miners/xmrig-upx;fi
  226. if [ -d /home/wareck/miners/xmr-stak ];then rm -r /home/wareck/miners/xmr-stak;fi
  227. if [ -d /home/wareck/miners/xmr-stak-rx ];then rm -r /home/wareck/miners/xmr-stak-rx;fi
  228. sudo chmod -R 775 /home/wareck/miners
  229. }
  230. function configure_ {
  231. echo -e "$(tput setaf 10)\nConfig files:$(tput sgr0)"
  232. cd /home/wareck/
  233. zip="['firefox.desktop', 'thunderbird.desktop', 'org.remmina.Remmina.desktop', 'filezilla.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Terminal.desktop']"
  234. cat <<'EOF'>> zap
  235. #!/bin/bash
  236. gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 32
  237. gsettings set org.gnome.desktop.background picture-uri /home/wareck/Images/mad-max-wallpapers.jpg
  238. gsettings set org.gnome.shell favorite-apps "XXX"
  239. #su wareck -c 'gsettings set org.gnome.shell.extensions.dash-to-dock show-mounts false'
  240. dconf load /org/gnome/terminal/ < /usr/local/bin/zap2
  241. EOF
  242. sed -i "s/XXX/$zip/g" zap
  243. UUID=$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d \')
  244. cat <<'EOF'>> zap2
  245. [legacy/profiles:/:XXX]
  246. background-transparency-percent=7
  247. font='Monospace 8'
  248. use-system-font=false
  249. use-theme-colors=false
  250. use-theme-transparency=false
  251. use-transparent-background=true
  252. background-transparency-percent=7
  253. default-size-columns=110
  254. EOF
  255. sed -i "s/XXX/$UUID/g" zap2
  256. chmod +x zap
  257. sudo cp zap /usr/local/bin
  258. sudo cp zap2 /usr/local/bin
  259. sudo rm zap
  260. sudo rm zap2
  261. sleep 1
  262. sudo rm -r -f /etc/update-motd.d/*
  263. tar xfJ pack1.tar.xz --checkpoint=.10
  264. echo -n -e "\n"
  265. sudo cp /home/wareck/pack2.tar.xz /
  266. sudo cp /home/wareck/pack3.tar.xz /
  267. cd /
  268. sudo tar xfJ pack2.tar.xz --checkpoint=.10
  269. sudo tar xfJ pack3.tar.xz --checkpoint=.10
  270. echo -n -e "\n"
  271. cd /home/wareck
  272. sudo sed -i -e "s/# set constantshow/set constantshow/g" /etc/nanorc
  273. if ! grep "wareck" /etc/sudoers >/dev/null
  274. then
  275. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  276. fi
  277. echo -e "$(tput setaf 10)\nBuild folder and mount drives:$(tput sgr0)"
  278. if ! [ -r /raid ]
  279. then
  280. sudo mkdir /raid
  281. fi
  282. if ! grep "#/swapfile" /etc/fstab >/dev/null
  283. then
  284. cp /etc/fstab /tmp/fstab
  285. sed -i '/ swap / s/^\(.*\)$/#\1/g' /tmp/fstab
  286. sudo cp /tmp/fstab /etc/fstab
  287. fi
  288. sudo rm /etc/hosts
  289. sudo cat <<'EOF'>> /etc/hosts
  290. 127.0.0.1 localhost
  291. 127.0.1.1 Jupiter
  292. 192.168.1.8 miniserver miniserver gogserver.dnsalias.com
  293. 192.168.1.10 nzxt
  294. 192.168.1.11 garage
  295. 192.168.1.100 cube
  296. 192.168.1.254 mafreebox.freebox.fr
  297. 192.168.1.200 node
  298. # The following lines are desirable for IPv6 capable hosts
  299. ::1 ip6-localhost ip6-loopback
  300. fe00::0 ip6-localnet
  301. ff00::0 ip6-mcastprefix
  302. ff02::1 ip6-allnodes
  303. ff02::2 ip6-allrouters
  304. EOF
  305. echo "Done."
  306. echo -e "$(tput setaf 10)\nW.O.L drivers:$(tput sgr0)"
  307. sudo apt install ethtool -y
  308. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{printf $2a}' | cut -d ' ' -f2)
  309. sudo ethtool --change $iface wol g
  310. cat <<'EOF'>> /tmp/wakemeup.sh
  311. #!/bin/bash
  312. set -e
  313. if ! [ -x "$(command -v etherwake)" ];then sudo apt-get install etherwake -y;fi
  314. clear
  315. echo -e "$(tput setaf 10)Wake On Lan v1.0:$(tput sgr0)"
  316. PS3="Select : "
  317. items=("Nzxt" "Garage" "Cube")
  318. select item in "${items[@]}" Quit
  319. do
  320. case $REPLY in
  321. 1) sudo etherwake -i enp5s0 98:03:CF:07:31:72 ; break;;
  322. 2) sudo etherwake -i enp5s0 58:11:22:CD:FC:7A ; break;;
  323. 3) sudo etherwake -i enp5s0 94:DE:80:2F:83:43 ; break;;
  324. $((${#items[@]}+1))) echo "We're done!"; break 2;;
  325. *) echo "Ooops - unknown choice $REPLY"; break;
  326. esac
  327. done
  328. echo -e ""
  329. EOF
  330. sudo chmod +x /tmp/wakemeup.sh
  331. sudo cp /tmp/wakemeup.sh /usr/local/bin
  332. echo "Done."
  333. echo -e "$(tput setaf 10)\nOpening ports:$(tput sgr0)"
  334. sudo ufw allow 8333 >/dev/null
  335. sudo ufw allow 22 >/dev/null
  336. sudo ufw allow 5900 >/dev/null
  337. sudo ufw allow 10000 >/dev/null
  338. sudo ufw allow 139 >/dev/null
  339. sudo ufw allow 5901 >/dev/null
  340. sudo ufw allow 5902 >/dev/null
  341. sudo ufw allow 445 >/dev/null
  342. sudo ufw allow 1337 >/dev/null
  343. sudo ufw allow 1447 >/dev/null
  344. echo "Done."
  345. echo -e "$(tput setaf 10)\nBashrc mod:$(tput sgr0)"
  346. if [ $Cuda = "YES" ]
  347. then
  348. if ! grep "#mod for cuda" /home/wareck/.bashrc >/dev/null
  349. then
  350. echo '#mod for cuda' >>/home/wareck/.bashrc
  351. echo 'export PATH=/usr/local/cuda-12.4/bin/:$PATH'>>/home/wareck/.bashrc
  352. echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:$LD_LIBRARY_PATH'>>/home/wareck/.bashrc
  353. echo '' >>/home/wareck/.bashrc
  354. fi
  355. fi
  356. echo -e "$(tput setaf 10)\nDisable IPv6:$(tput sgr0)"
  357. if ! grep "ipv6.disable=1" /etc/default/grub >/dev/null
  358. then
  359. sed -i -e "s/quiet splash/quiet splash ipv6.disable=1/g" /etc/default/grub
  360. sed -i -e "s/GRUB_CMDLINE_LINUX=\"/GRUB_CMDLINE_LINUX=\"ipv6.disable=1 acpi_enforce_resources=lax/g" /etc/default/grub
  361. sudo update-grub2
  362. fi
  363. sudo chown -R wareck:wareck /home/wareck/miners/xmr*
  364. sudo apt-get remove light-locker* -y
  365. if [ ! -d /home/wareck/.config/lxpanel/LXDE/panels ]
  366. then
  367. mkdir /home/wareck/.config/lxpanel
  368. mkdir /home/wareck/.config/lxpanel/LXDE
  369. mkdir /home/wareck/.config/lxpanel/LXDE/panels
  370. fi
  371. sudo cp /home/wareck/Build_Cube/pack/panel /home/wareck/.config/lxpanel/LXDE/panels/panel
  372. sudo chmod 777 /home/wareck/.config/lxpanel/LXDE/panels/panel
  373. if [ ! -d /home/wareck/.config/lxterminal ]
  374. then
  375. mkdir /home/wareck/.config/lxterminal
  376. fi
  377. sudo cp /home/wareck/Build_Cube/pack/lxterminal.conf /home/wareck/.config/lxterminal/
  378. sudo chmod 777 /home/wareck/.config/lxterminal/lxterminal.conf
  379. echo "Done."
  380. echo "passe=4" >/home/wareck/.ipass
  381. decompte_
  382. }
  383. function mounting_drives_ {
  384. echo -e "$(tput setaf 10)\nMounting Drives$(tput sgr0)"
  385. #if ! findmnt /store >/dev/null ; then sudo mount /store |null ;fi
  386. #sudo chmod 777 /store
  387. sudo chmod 777 /raid
  388. echo "Done."
  389. }
  390. function cleaning_ {
  391. echo -e "$(tput setaf 10)\nCleaning install files:$(tput sgr0)"
  392. if [ -f /pack2.tar.xz ]; then sudo rm /pack2.tar.xz ;fi
  393. if [ -f /pack3.tar.xz ]; then sudo rm /pack3.tar.xz ;fi
  394. if [ -f /home/wareck/pack1.tar.xz ]; then rm /home/wareck/pack1.tar.xz ;fi
  395. if [ -f /home/wareck/pack2.tar.xz ]; then rm /home/wareck/pack2.tar.xz ;fi
  396. if [ -f /home/wareck/pack3.tar.xz ]; then rm /home/wareck/pack3.tar.xz ;fi
  397. if [ -f /home/wareck/xmrig.tar.xz ]; then rm /home/wareck/xmrig.tar.xz ;fi
  398. if [ -f /home/wareck/gpu-miners.tar.xz ]; then rm /home/wareck/gpu-miners.tar.xz;fi
  399. if [ -r /home/wareck/Music ]; then sudo rm -r -f /home/wareck/Music ;fi
  400. if [ -r /home/wareck/Public ]; then sudo rm -r -f /home/wareck/Public ;fi
  401. if [ -r /home/wareck/Templates ]; then sudo rm -r -f /home/wareck/Templates ;fi
  402. if [ -r /home/wareck/Vidéos ]; then sudo rm -r -f /home/wareck/Vidéos ;fi
  403. if [ -f /home/wareck/NVIDIA-Linux-x86_64-470.74.run ]; then rm /home/wareck/NVIDIA-Linux-x86_64-470.74.run ;fi
  404. 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
  405. if [ -f /home/wareck/.ipass ]; then rm /home/wareck/.ipass ;fi
  406. if [ -f /usr/local/bin/zap ]; then sudo rm /usr/local/bin/zap* ;fi
  407. if [ -f /home/wareck/.config/autostart/install_os.desktop ];then sudo rm /home/wareck/.config/autostart/install_os.desktop;fi
  408. if [ -f /home/wareck/.config/autostart/zappy.desktop ];then sudo rm /home/wareck/.config/autostart/zappy.desktop;fi
  409. if [ -r /lib/modules/5.15.0-60-generic ]; then sudo rm -r /lib/modules/5.15.0-60-generic ;fi
  410. if [ -r /lib/modules/5.15.0-46-generic ]; then sudo rm -r /lib/modules/5.15.0-46-generic ;fi
  411. if [ -r /lib/modules/5.15.0-70-generic ]; then sudo rm -r /lib/modules/5.15.0-70-generic ;fi
  412. cd /home/wareck/Build_Cube/pack
  413. sudo chown -R wareck:wareck /home/wareck/miners
  414. sudo chmod -R 775 /home/wareck/miners
  415. ./clean.sh
  416. echo -e "Done. \n"
  417. echo `date` "install/update" >/home/wareck/.buildcube
  418. sudo apt-get autoremove -y
  419. sleep 1
  420. }
  421. function autoroot_ {
  422. if ! grep "#color putty" ~/.bashrc >/dev/null
  423. then
  424. echo "#color putty" >> ~/.bashrc
  425. echo "export TERM=xterm-256color" >> ~/.bashrc
  426. fi
  427. if [ ! -d /home/wareck/.config/autostart ]
  428. then
  429. echo -e "$(tput setaf 10)\nInit install & autostart:$(tput sgr0)"
  430. mkdir /home/wareck/.config/autostart
  431. echo -e "Done."
  432. sleep 1
  433. fi
  434. if [ ! -f /home/wareck/.config/autostart/install_os.desktop ]
  435. then
  436. cat <<'EOF'>> /home/wareck/.config/autostart/install_os.desktop
  437. [Desktop Entry]
  438. # VERSION=3.36.2
  439. Name=Terminal
  440. Comment=Use the command line
  441. Keywords=shell;prompt;command;commandline;cmd;
  442. TryExec=gnome-terminal
  443. Exec=gnome-terminal -- bash -c "sudo /home/wareck/Build_Cube/jupiter.sh; exec bash"
  444. Icon=org.gnome.Terminal
  445. Type=Application
  446. Categories=GNOME;GTK;System;TerminalEmulator;
  447. StartupNotify=true
  448. X-GNOME-SingleWindow=false
  449. OnlyShowIn=GNOME;Unity;
  450. Actions=new-window;preferences;
  451. X-Ubuntu-Gettext-Domain=gnome-terminal
  452. [Desktop Action new-window]
  453. Name=New Window
  454. Exec=gnome-terminal --window
  455. [Desktop Action preferences]
  456. Name=Preferences
  457. Exec=gnome-terminal --preferences
  458. EOF
  459. chmod +x /home/wareck/.config/autostart/install_os.desktop
  460. fi
  461. if [ ! -f /home/wareck/.config/autostart/zappy.desktop ]
  462. then
  463. cat <<'EOF'>> /home/wareck/.config/autostart/zappy.desktop
  464. [Desktop Entry]
  465. # VERSION=3.36.2
  466. Name=Terminal
  467. Comment=Use the command line
  468. Keywords=shell;prompt;command;commandline;cmd;
  469. TryExec=gnome-terminal
  470. Exec=gnome-terminal -- bash -c "/usr/local/bin/zap"
  471. Icon=org.gnome.Terminal
  472. Type=Application
  473. Categories=GNOME;GTK;System;TerminalEmulator;
  474. StartupNotify=true
  475. X-GNOME-SingleWindow=false
  476. OnlyShowIn=GNOME;Unity;
  477. Actions=new-window;preferences;
  478. X-Ubuntu-Gettext-Domain=gnome-terminal
  479. [Desktop Action new-window]
  480. Name=New Window
  481. Exec=gnome-terminal --window
  482. [Desktop Action preferences]
  483. Name=Preferences
  484. Exec=gnome-terminal --preferences
  485. EOF
  486. chmod +x /home/wareck/.config/autostart/zappy.desktop
  487. fi
  488. if ! grep "wareck" /etc/sudoers >/dev/null
  489. then
  490. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  491. fi
  492. if [ $passe="2" ]
  493. then
  494. echo -e "$(tput setaf 10)\nUpdate and install packages:$(tput sgr0)"
  495. sudo apt-get update
  496. sleep 1
  497. fi
  498. }
  499. function remove_screensaver {
  500. #remove screensaver
  501. cat <<EOF>> autostart
  502. @lxpanel --profile LXDE
  503. @pcmanfm --desktop --profile LXDE
  504. EOF
  505. sudo chmod 744 autostart
  506. sudo cp autostart /etc/xdg/lxsession/LXDE/
  507. sudo cp autostart /home/wareck/.config/lxsession/LXDE/
  508. sudo rm autostart
  509. sudo apt-get remove xscreensaver xscreensaver-data -y
  510. }
  511. function cmake_ {
  512. pids=""
  513. /home/wareck/Build_Cube/options/tools/_cmake.sh rollback & pids="$pids $!"
  514. wait $pids
  515. sudo ldconfig
  516. }
  517. function watchdog_ {
  518. pids=""
  519. /home/wareck/Build_Cube/options/watchdog.sh ext & pids="$pids $!"
  520. wait $pids
  521. }
  522. function chia_ {
  523. echo -e "$(tput setaf 10)\nInstall Chia:$(tput sgr0)"
  524. cd /home/wareck/Build_Cube/
  525. cp /home/wareck/Build_Cube/options/chia.sh .
  526. sed -i "s/Gui=Yes/Gui=No/g" chia.sh
  527. sed -i "s/ChiaPos=Yes/ChiaPos=No/g" chia.sh
  528. sed -i "s/Miner=Yes/Miner=No/g" chia.sh
  529. sed -i "s/ChiaService=Yes/ChiaService=No/g" chia.sh
  530. sed -i "s/Miner=Yes/Miner=No/g" chia.sh
  531. sed -i "s/ChiaProxy=Yes/ChiaProxy=No/g" chia.sh
  532. sed -i "s/Toolkit for Chia v$Version/Toolkit for Chia AlmaLinux /g" chia.sh
  533. sed -i "s/sudo apt-get install/#sudo apt-get install/g" chia.sh
  534. sed -i "s/-j 6/-j 32/g" chia.sh
  535. chmod +x chia.sh
  536. bash chia.sh
  537. #rm chia.sh
  538. echo -e "\nDone"
  539. }
  540. function wol_ {
  541. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{printf $2a}' | cut -d ' ' -f2)
  542. ether=$(which ethtool)
  543. echo "[Unit]" >>/tmp/wol.service
  544. echo "Description=Enable Wake On Lan" >>/tmp/wol.service
  545. echo "" >>/tmp/wol.service
  546. echo "[Service]" >>/tmp/wol.service
  547. echo "Type=oneshot" >>/tmp/wol.service
  548. echo "ExecStart = $ether --change $iface wol g" >>/tmp/wol.service
  549. echo "" >>/tmp/wol.service
  550. echo "[Install]" >>/tmp/wol.service
  551. echo "WantedBy=basic.target" >>/tmp/wol.service
  552. sudo cp /tmp/wol.service /etc/systemd/system/wol.service
  553. sudo systemctl daemon-reload >/dev/null
  554. sudo systemctl enable wol.service >/dev/null
  555. sudo systemctl start wol.service >/dev/null
  556. sleep 2
  557. clear
  558. }
  559. intro_
  560. case $passe in
  561. 1)
  562. watchdog_
  563. autoroot_
  564. ubuntu_version_check
  565. update_
  566. kernel_check_
  567. nvidia_driver_
  568. ;;
  569. 2)
  570. nvidia_driver_
  571. update_
  572. ;;
  573. 3)
  574. download_packs_
  575. build_miners_
  576. configure_
  577. ;;
  578. 4)
  579. mounting_drives_
  580. cleaning_
  581. remove_screensaver
  582. clear
  583. wol_
  584. dynmotd
  585. ;;
  586. *) ;;
  587. esac
  588. echo -e "$(tput setaf 10)\nEnd of script:$(tput sgr0) \n"
  589. echo -e "$(tput setaf 7)Need to install webmin manually (reboot required)$(tput sgr0)"
  590. echo -e "$(tput setaf 7)after install webmin, reboot is required $(tput sgr0)"
  591. echo -e ""