jupiter.sh 21 KB

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