edge.sh 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  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/kernel_5.15.152-custom-edge.run
  115. #chmod +x kernel_5.15.152-custom-edge.run
  116. #sudo ./kernel_5.15.152-custom-edge.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=1df72b63-fca0-45c6-992c-3e2532d5591a /media/Store ext4 auto,nofail,noatime,rw,user 0 0
  287. #btrfs 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. sudo apt install ethtool -y
  312. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{printf $2a}' | cut -d ' ' -f2)
  313. sudo ethtool --change $iface wol g
  314. cat <<'EOF'>> /tmp/wakemeup.sh
  315. #!/bin/bash
  316. set -e
  317. if ! [ -x "$(command -v etherwake)" ];then sudo apt-get install etherwake -y;fi
  318. clear
  319. echo -e "$(tput setaf 10)Wake On Lan v1.0:$(tput sgr0)"
  320. PS3="Select : "
  321. items=("Nzxt" "Garage" "Blade")
  322. select item in "${items[@]}" Quit
  323. do
  324. case $REPLY in
  325. 1) sudo etherwake -i enp5s0 E0:D5:5E:2D:9E:CB ; break;;
  326. 2) sudo etherwake -i enp5s0 58:11:22:CD:FC:7A ; break;;
  327. 3) sudo etherwake -i enp5s0 78:AC:44:57:3C:50 ; break;;
  328. $((${#items[@]}+1))) echo "We're done!"; break 2;;
  329. *) echo "Ooops - unknown choice $REPLY"; break;
  330. esac
  331. done
  332. echo -e ""
  333. EOF
  334. sudo chmod +x /tmp/wakemeup.sh
  335. sudo cp /tmp/wakemeup.sh /usr/local/bin
  336. echo "Done."
  337. echo -e "$(tput setaf 10)\nVnc init:$(tput sgr0)"
  338. sudo update-rc.d vncserver defaults
  339. echo "Done."
  340. echo -e "$(tput setaf 10)\nOpening ports:$(tput sgr0)"
  341. sudo ufw allow 8333 >/dev/null
  342. sudo ufw allow 22 >/dev/null
  343. sudo ufw allow 5900 >/dev/null
  344. sudo ufw allow 10000 >/dev/null
  345. sudo ufw allow 139 >/dev/null
  346. sudo ufw allow 5901 >/dev/null
  347. sudo ufw allow 5902 >/dev/null
  348. sudo ufw allow 445 >/dev/null
  349. sudo ufw allow 1337 >/dev/null
  350. sudo ufw allow 1447 >/dev/null
  351. echo "Done."
  352. echo -e "$(tput setaf 10)\nBashrc mod:$(tput sgr0)"
  353. if [ $Cuda = "YES" ]
  354. then
  355. if ! grep "#mod for cuda" /home/wareck/.bashrc >/dev/null
  356. then
  357. echo '#mod for cuda' >>/home/wareck/.bashrc
  358. echo 'export PATH=/usr/local/cuda-12.3/bin/:$PATH'>>/home/wareck/.bashrc
  359. echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64:$LD_LIBRARY_PATH'>>/home/wareck/.bashrc
  360. echo '' >>/home/wareck/.bashrc
  361. fi
  362. fi
  363. if ! grep "#mod for tightvncserver" /home/wareck/.bashrc >/dev/null
  364. then
  365. echo '#mod for tightvncserver' >>/home/wareck/.bashrc
  366. echo 'cd ~' >>/home/wareck/.bashrc
  367. fi
  368. echo "Done."
  369. echo -e "$(tput setaf 10)\nDisable IPv6:$(tput sgr0)"
  370. if ! grep "ipv6.disable=1" /etc/default/grub >/dev/null
  371. then
  372. sed -i -e "s/quiet splash/quiet splash ipv6.disable=1/g" /etc/default/grub
  373. sed -i -e "s/GRUB_CMDLINE_LINUX=\"/GRUB_CMDLINE_LINUX=\"ipv6.disable=1 acpi_enforce_resources=lax/g" /etc/default/grub
  374. sudo update-grub2
  375. fi
  376. sudo chown -R wareck:wareck /home/wareck/miners/xmr*
  377. sudo apt-get remove light-locker* -y
  378. if [ ! -d /home/wareck/.config/lxpanel/LXDE/panels ]
  379. then
  380. mkdir /home/wareck/.config/lxpanel
  381. mkdir /home/wareck/.config/lxpanel/LXDE
  382. mkdir /home/wareck/.config/lxpanel/LXDE/panels
  383. fi
  384. sudo cp /home/wareck/Build_Cube/pack/panel /home/wareck/.config/lxpanel/LXDE/panels/panel
  385. sudo chmod 777 /home/wareck/.config/lxpanel/LXDE/panels/panel
  386. if [ ! -d /home/wareck/.config/lxterminal ]
  387. then
  388. mkdir /home/wareck/.config/lxterminal
  389. fi
  390. sudo cp /home/wareck/Build_Cube/pack/lxterminal.conf /home/wareck/.config/lxterminal/
  391. sudo chmod 777 /home/wareck/.config/lxterminal/lxterminal.conf
  392. echo "Done."
  393. echo "passe=4" >/home/wareck/.ipass
  394. decompte_
  395. }
  396. function printer_ {
  397. if [ ! -d /usr/local/share/foomatic/ ]
  398. then
  399. if [ ! -d /tmp/foomatic-db/ ]
  400. then
  401. cd /tmp/
  402. echo -e "$(tput setaf 10)\nInstall printers generic drivers:$(tput sgr0)"
  403. git clone https://github.com/OpenPrinting/foomatic-db.git
  404. fi
  405. cd /tmp/foomatic-db
  406. if [ ! -d /usr/local/share/foomatic/ ]
  407. then
  408. ./make_configure
  409. ./configure
  410. sudo make install
  411. echo "Done."
  412. fi
  413. fi
  414. }
  415. function mounting_drives_ {
  416. echo -e "$(tput setaf 10)\nMounting Drives$(tput sgr0)"
  417. #if ! findmnt /store >/dev/null ; then sudo mount /store |null ;fi
  418. #sudo chmod 777 /store
  419. #sudo chmod 777 /raid
  420. echo "Done."
  421. }
  422. function cleaning_ {
  423. echo -e "$(tput setaf 10)\nCleaning install files:$(tput sgr0)"
  424. if [ -f /pack2.tar.xz ]; then sudo rm /pack2.tar.xz ;fi
  425. if [ -f /pack3.tar.xz ]; then sudo rm /pack3.tar.xz ;fi
  426. if [ -f /home/wareck/pack1.tar.xz ]; then rm /home/wareck/pack1.tar.xz ;fi
  427. if [ -f /home/wareck/pack2.tar.xz ]; then rm /home/wareck/pack2.tar.xz ;fi
  428. if [ -f /home/wareck/pack3.tar.xz ]; then rm /home/wareck/pack3.tar.xz ;fi
  429. if [ -f /home/wareck/xmrig.tar.xz ]; then rm /home/wareck/xmrig.tar.xz ;fi
  430. if [ -f /home/wareck/gpu-miners.tar.xz ]; then rm /home/wareck/gpu-miners.tar.xz;fi
  431. if [ -r /home/wareck/Music ]; then sudo rm -r -f /home/wareck/Music ;fi
  432. if [ -r /home/wareck/Public ]; then sudo rm -r -f /home/wareck/Public ;fi
  433. if [ -r /home/wareck/Templates ]; then sudo rm -r -f /home/wareck/Templates ;fi
  434. if [ -r /home/wareck/Vidéos ]; then sudo rm -r -f /home/wareck/Vidéos ;fi
  435. if [ -f /home/wareck/NVIDIA-Linux-x86_64-470.74.run ]; then rm /home/wareck/NVIDIA-Linux-x86_64-470.74.run ;fi
  436. 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
  437. if [ -f /home/wareck/.ipass ]; then rm /home/wareck/.ipass ;fi
  438. if [ -f /usr/local/bin/zap ]; then sudo rm /usr/local/bin/zap* ;fi
  439. if [ -f /home/wareck/.config/autostart/install_os.desktop ];then sudo rm /home/wareck/.config/autostart/install_os.desktop;fi
  440. if [ -f /home/wareck/.config/autostart/zappy.desktop ];then sudo rm /home/wareck/.config/autostart/zappy.desktop;fi
  441. if [ -r /lib/modules/5.15.0-60-generic ]; then sudo rm -r /lib/modules/5.15.0-60-generic ;fi
  442. if [ -r /lib/modules/5.15.0-46-generic ]; then sudo rm -r /lib/modules/5.15.0-46-generic ;fi
  443. if [ -r /lib/modules/5.15.0-70-generic ]; then sudo rm -r /lib/modules/5.15.0-70-generic ;fi
  444. cd /home/wareck/Build_Cube/pack
  445. sudo chown -R wareck:wareck /home/wareck/miners
  446. sudo chmod -R 775 /home/wareck/miners
  447. ./clean.sh
  448. echo -e "Done. \n"
  449. echo `date` "install/update" >/home/wareck/.buildcube
  450. sudo apt-get autoremove -y
  451. sleep 1
  452. }
  453. function autoroot_ {
  454. if ! grep "#color putty" ~/.bashrc >/dev/null
  455. then
  456. echo "#color putty" >> ~/.bashrc
  457. echo "export TERM=xterm-256color" >> ~/.bashrc
  458. fi
  459. if [ ! -d /home/wareck/.config/autostart ]
  460. then
  461. echo -e "$(tput setaf 10)\nInit install & autostart:$(tput sgr0)"
  462. mkdir /home/wareck/.config/autostart
  463. echo -e "Done."
  464. sleep 1
  465. fi
  466. if [ ! -f /home/wareck/.config/autostart/install_os.desktop ]
  467. then
  468. cat <<'EOF'>> /home/wareck/.config/autostart/install_os.desktop
  469. [Desktop Entry]
  470. # VERSION=3.36.2
  471. Name=Terminal
  472. Comment=Use the command line
  473. Keywords=shell;prompt;command;commandline;cmd;
  474. TryExec=gnome-terminal
  475. Exec=gnome-terminal -- bash -c "sudo /home/wareck/Build_Cube/edge.sh; exec bash"
  476. Icon=org.gnome.Terminal
  477. Type=Application
  478. Categories=GNOME;GTK;System;TerminalEmulator;
  479. StartupNotify=true
  480. X-GNOME-SingleWindow=false
  481. OnlyShowIn=GNOME;Unity;
  482. Actions=new-window;preferences;
  483. X-Ubuntu-Gettext-Domain=gnome-terminal
  484. [Desktop Action new-window]
  485. Name=New Window
  486. Exec=gnome-terminal --window
  487. [Desktop Action preferences]
  488. Name=Preferences
  489. Exec=gnome-terminal --preferences
  490. EOF
  491. chmod +x /home/wareck/.config/autostart/install_os.desktop
  492. fi
  493. if [ ! -f /home/wareck/.config/autostart/zappy.desktop ]
  494. then
  495. cat <<'EOF'>> /home/wareck/.config/autostart/zappy.desktop
  496. [Desktop Entry]
  497. # VERSION=3.36.2
  498. Name=Terminal
  499. Comment=Use the command line
  500. Keywords=shell;prompt;command;commandline;cmd;
  501. TryExec=gnome-terminal
  502. Exec=gnome-terminal -- bash -c "/usr/local/bin/zap"
  503. Icon=org.gnome.Terminal
  504. Type=Application
  505. Categories=GNOME;GTK;System;TerminalEmulator;
  506. StartupNotify=true
  507. X-GNOME-SingleWindow=false
  508. OnlyShowIn=GNOME;Unity;
  509. Actions=new-window;preferences;
  510. X-Ubuntu-Gettext-Domain=gnome-terminal
  511. [Desktop Action new-window]
  512. Name=New Window
  513. Exec=gnome-terminal --window
  514. [Desktop Action preferences]
  515. Name=Preferences
  516. Exec=gnome-terminal --preferences
  517. EOF
  518. chmod +x /home/wareck/.config/autostart/zappy.desktop
  519. fi
  520. if ! grep "wareck" /etc/sudoers >/dev/null
  521. then
  522. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  523. fi
  524. if [ $passe="2" ]
  525. then
  526. echo -e "$(tput setaf 10)\nUpdate and install packages:$(tput sgr0)"
  527. sudo apt-get update
  528. sudo apt-get install lxde lxde-icon-theme -y
  529. sleep 1
  530. fi
  531. }
  532. function remove_screensaver {
  533. #remove screensaver
  534. cat <<EOF>> autostart
  535. @lxpanel --profile LXDE
  536. @pcmanfm --desktop --profile LXDE
  537. EOF
  538. sudo chmod 744 autostart
  539. sudo cp autostart /etc/xdg/lxsession/LXDE/
  540. sudo cp autostart /home/wareck/.config/lxsession/LXDE/
  541. sudo rm autostart
  542. sudo apt-get remove xscreensaver xscreensaver-data -y
  543. }
  544. function cmake_ {
  545. pids=""
  546. /home/wareck/Build_Cube/options/tools/_cmake.sh rollback & pids="$pids $!"
  547. wait $pids
  548. sudo ldconfig
  549. }
  550. function watchdog_ {
  551. pids=""
  552. /home/wareck/Build_Cube/options/watchdog.sh ext & pids="$pids $!"
  553. wait $pids
  554. }
  555. function chia_ {
  556. echo -e "$(tput setaf 10)\nInstall Chia:$(tput sgr0)"
  557. cd /home/wareck/Build_Cube/
  558. cp /home/wareck/Build_Cube/options/chia.sh .
  559. sed -i "s/Gui=Yes/Gui=No/g" chia.sh
  560. sed -i "s/ChiaPos=Yes/ChiaPos=No/g" chia.sh
  561. sed -i "s/Miner=Yes/Miner=No/g" chia.sh
  562. sed -i "s/ChiaService=Yes/ChiaService=No/g" chia.sh
  563. sed -i "s/Miner=Yes/Miner=No/g" chia.sh
  564. sed -i "s/ChiaProxy=Yes/ChiaProxy=No/g" chia.sh
  565. sed -i "s/Toolkit for Chia v$Version/Toolkit for Chia AlmaLinux /g" chia.sh
  566. sed -i "s/sudo apt-get install/#sudo apt-get install/g" chia.sh
  567. sed -i "s/-j 6/-j 32/g" chia.sh
  568. chmod +x chia.sh
  569. bash chia.sh
  570. #rm chia.sh
  571. echo -e "\nDone"
  572. }
  573. function wol_ {
  574. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{printf $2a}' | cut -d ' ' -f2)
  575. ether=$(which ethtool)
  576. echo "[Unit]" >>/tmp/wol.service
  577. echo "Description=Enable Wake On Lan" >>/tmp/wol.service
  578. echo "" >>/tmp/wol.service
  579. echo "[Service]" >>/tmp/wol.service
  580. echo "Type=oneshot" >>/tmp/wol.service
  581. echo "ExecStart = $ether --change $iface wol g" >>/tmp/wol.service
  582. echo "" >>/tmp/wol.service
  583. echo "[Install]" >>/tmp/wol.service
  584. echo "WantedBy=basic.target" >>/tmp/wol.service
  585. sudo cp /tmp/wol.service /etc/systemd/system/wol.service
  586. sudo systemctl daemon-reload >/dev/null
  587. sudo systemctl enable wol.service >/dev/null
  588. sudo systemctl start wol.service >/dev/null
  589. sleep 2
  590. clear
  591. }
  592. intro_
  593. case $passe in
  594. 1)
  595. watchdog_
  596. autoroot_
  597. ubuntu_version_check
  598. update_
  599. kernel_check_
  600. nvidia_driver_
  601. ;;
  602. 2)
  603. nvidia_driver_
  604. update_
  605. ;;
  606. 3)
  607. download_packs_
  608. printer_
  609. build_miners_
  610. configure_
  611. ;;
  612. 4)
  613. mounting_drives_
  614. cleaning_
  615. remove_screensaver
  616. clear
  617. wol_
  618. dynmotd
  619. ;;
  620. *) ;;
  621. esac
  622. echo -e "$(tput setaf 10)\nEnd of script:$(tput sgr0) \n"
  623. echo -e "$(tput setaf 7)Need to install webmin manually (reboot required)$(tput sgr0)"
  624. echo -e "$(tput setaf 7)after install webmin, reboot is required $(tput sgr0)"
  625. echo -e ""