edge.sh 21 KB

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