edge.sh 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  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 5)"
  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-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/cgminer.conf -O /home/wareck/Build_Cube/pack/cgminer.conf
  176. 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
  177. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/gerbera.tar.xz -O /home/wareck/Build_Cube/pack/gerbera.tar.xz
  178. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/start_cgminer.tar.xz -O /home/wareck/Build_Cube/pack/start_cgminer.tar.xz
  179. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/$Webmin.tar.xz -O /home/wareck/Build_Cube/pack/$Webmin.tar.xz
  180. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/xmrig.tar.xz -O /home/wareck/Build_Cube/pack/xmrig.tar.xz
  181. 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
  182. 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
  183. cp /home/wareck/Build_Cube/pack/gpu-miners.tar.xz /home/wareck
  184. cp /home/wareck/Build_Cube/pack/pack1.tar.xz /home/wareck
  185. cp /home/wareck/Build_Cube/pack/pack2.tar.xz /home/wareck
  186. cp /home/wareck/Build_Cube/pack/pack3.tar.xz /home/wareck
  187. cp /home/wareck/Build_Cube/pack/xmrig.tar.xz /home/wareck
  188. cp /home/wareck/Build_Cube/pack/start_cgminer.tar.xz /home/wareck
  189. echo -e "Done."
  190. if [ ! -d /home/wareck/$Webmin ]
  191. then
  192. cp /home/wareck/Build_Cube/pack/$Webmin.tar.xz /home/wareck/
  193. cd /home/wareck/
  194. echo -e "$(tput setaf 10)\nWebmin uncompress:$(tput sgr0)"
  195. tar xfJ $Webmin.tar.xz
  196. rm $Webmin.tar.xz
  197. echo -e "Done"
  198. fi
  199. echo -e "$(tput setaf 10)\nDownloading miners:$(tput sgr0)"
  200. cd /home/wareck
  201. if ! [ -d miners ]; then mkdir -p miners;fi
  202. cd /home/wareck/miners
  203. if ! [ -d xmrig ]
  204. then
  205. git clone https://github.com/xmrig/xmrig.git
  206. echo -e ""
  207. fi
  208. echo -e "Done.\n"
  209. }
  210. function build_miners_ {
  211. cmake_ #check cmake version
  212. cd /home/wareck
  213. tar xfJ gpu-miners.tar.xz
  214. cd /home/wareck/miners
  215. echo -e "$(tput setaf 10)\nUncompress xmr files:$(tput sgr0)"
  216. tar xfJ /home/wareck/xmrig.tar.xz --checkpoint=.100
  217. echo "Done."
  218. echo -n -e "\n"
  219. echo -e "$(tput setaf 10)\nBuild xmrig:$(tput sgr0)"
  220. cd xmrig
  221. git config --global --add safe.directory /home/wareck/miners/xmrig
  222. git pull
  223. sed -i "s/kDefaultDonateLevel = 5;/kDefaultDonateLevel = 0;/g" src/donate.h
  224. sed -i "s/kMinimumDonateLevel = 1;/kMinimumDonateLevel = 0;/g" src/donate.h
  225. cd scripts
  226. ./build_deps.sh
  227. cd ..
  228. cd build
  229. cmake .. -DXMRIG_DEPS=scripts/deps
  230. make -j$((`nproc`))
  231. cd ..
  232. echo "Done."
  233. #Reduce mode
  234. if [ -d /home/wareck/miners/xmrig-upx ];then rm -r /home/wareck/miners/xmrig-upx;fi
  235. if [ -d /home/wareck/miners/xmr-stak ];then rm -r /home/wareck/miners/xmr-stak;fi
  236. if [ -d /home/wareck/miners/xmr-stak-rx ];then rm -r /home/wareck/miners/xmr-stak-rx;fi
  237. sudo chmod -R 775 /home/wareck/miners
  238. }
  239. function configure_ {
  240. echo -e "$(tput setaf 10)\nlxPanel sensors:$(tput sgr0)"
  241. cd /home/wareck
  242. if ! [ -d sensors-lxpanel-plugin ]
  243. then
  244. git clone https://github.com/danamlund/sensors-lxpanel-plugin.git
  245. fi
  246. cd /home/wareck
  247. cd sensors-lxpanel-plugin
  248. make
  249. sudo make install
  250. sudo rm -r /home/wareck/sensors-lxpanel-plugin
  251. echo "Done."
  252. echo -e "$(tput setaf 10)\nConfig files:$(tput sgr0)"
  253. cd /home/wareck/
  254. zip="['firefox.desktop', 'thunderbird.desktop', 'org.remmina.Remmina.desktop', 'filezilla.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Terminal.desktop']"
  255. cat <<'EOF'>> zap
  256. #!/bin/bash
  257. gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 32
  258. gsettings set org.gnome.desktop.background picture-uri /home/wareck/Images/mr-robot-wallpapers.jpg
  259. gsettings set org.gnome.shell favorite-apps "XXX"
  260. #su wareck -c 'gsettings set org.gnome.shell.extensions.dash-to-dock show-mounts false'
  261. dconf load /org/gnome/terminal/ < /usr/local/bin/zap2
  262. EOF
  263. sed -i "s/XXX/$zip/g" zap
  264. UUID=$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d \')
  265. cat <<'EOF'>> zap2
  266. [legacy/profiles:/:XXX]
  267. default-size-columns=110
  268. font='Monospace 9'
  269. use-system-font=false
  270. use-theme-colors=false
  271. EOF
  272. sed -i "s/XXX/$UUID/g" zap2
  273. chmod +x zap
  274. sudo cp zap /usr/local/bin
  275. sudo cp zap2 /usr/local/bin
  276. sudo rm zap
  277. sudo rm zap2
  278. sleep 1
  279. sudo rm -r -f /etc/update-motd.d/*
  280. tar xfJ pack1.tar.xz --checkpoint=.10
  281. echo -n -e "\n"
  282. sudo cp /home/wareck/pack2.tar.xz /
  283. sudo cp /home/wareck/pack3.tar.xz /
  284. cd /
  285. sudo tar xfJ pack2.tar.xz --checkpoint=.10
  286. sudo tar xfJ pack3.tar.xz --checkpoint=.10
  287. echo -n -e "\n"
  288. cd /home/wareck
  289. sudo sed -i -e "s/# set constantshow/set constantshow/g" /etc/nanorc
  290. if ! grep "wareck" /etc/sudoers >/dev/null
  291. then
  292. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  293. fi
  294. echo -e "$(tput setaf 10)\nBuild folder and mount drives:$(tput sgr0)"
  295. if ! [ -r /store ];then sudo mkdir /store;fi
  296. if ! [ -r /raid ];then sudo mkdir /raid;fi
  297. if ! grep "UUID=1df72b63-fca0-45c6-992c-3e2532d5591a /media/Store ext4" /etc/fstab >/dev/null
  298. then
  299. cp /etc/fstab /tmp/fstab
  300. cat <<"EOF">> /tmp/fstab
  301. #ext4
  302. #UUID=1df72b63-fca0-45c6-992c-3e2532d5591a /media/Store ext4 auto,nofail,noatime,rw,user 0 0
  303. #btrfs temporary drives
  304. #/dev/md0 /raid btrfs ssd,nodatasum,nobarrier,nodatacow,discard=async,noatime 0 0
  305. #Chia drive
  306. EOF
  307. sudo cp /tmp/fstab /etc/fstab
  308. fi
  309. sudo rm /etc/hosts
  310. sudo cat <<'EOF'>> /etc/hosts
  311. 127.0.0.1 localhost
  312. 127.0.1.1 poweredge
  313. 192.168.1.8 miniserver miniserver gogserver.dnsalias.com
  314. 192.168.1.10 nzxt
  315. 192.168.1.11 garage
  316. 192.168.1.100 cube
  317. 192.168.1.254 mafreebox.freebox.fr
  318. 192.168.1.200 node
  319. # The following lines are desirable for IPv6 capable hosts
  320. ::1 ip6-localhost ip6-loopback
  321. fe00::0 ip6-localnet
  322. ff00::0 ip6-mcastprefix
  323. ff02::1 ip6-allnodes
  324. ff02::2 ip6-allrouters
  325. EOF
  326. echo "Done."
  327. echo -e "$(tput setaf 10)\nSensors drivers:$(tput sgr0)"
  328. if ! grep "it87" /etc/modules >/dev/null
  329. then
  330. cp /etc/modules /tmp/modules
  331. cat <<"EOF">> /tmp/modules
  332. # Chip drivers
  333. it87
  334. EOF
  335. sudo cp /tmp/modules /etc/modules
  336. fi
  337. if [ -f /tmp/sensors3.conf ]
  338. then
  339. chmod 777 /tmp/sensors3.conf
  340. rm /tmp/sensors3.conf
  341. fi
  342. cat <<'EOF'>> /tmp/sensors3.conf
  343. chip "it8728-isa-0228"
  344. label in0 "Vcore"
  345. label in1 "Vdram" # "DDR3" in BIOS
  346. label in2 "+3.3V"
  347. label in3 "+5V" # Not in BIOS
  348. label in4 "+12V"
  349. ignore in5 # -12V unused
  350. ignore in6
  351. label in7 "5VSB" # Not in BIOS
  352. label in8 "Vbat" # Not in BIOS
  353. compute in3 @ * (6.8/10+1), @ / (6.8/10+1)
  354. compute in4 @ * 3.963, @ / 3.963
  355. compute in7 @ * (6.8/10+1), @ / (6.8/10+1)
  356. set in0_min 0.825 * 0.95
  357. set in0_max 1.425 * 1.05
  358. set in1_min 1.5 * 0.95
  359. set in1_max 1.5 * 1.05
  360. set in2_min 3.3 * 0.95
  361. set in2_max 3.3 * 1.05
  362. set in3_min 5 * 0.95
  363. set in3_max 5 * 1.05
  364. set in4_min 12 * 0.95
  365. set in4_max 12 * 1.05
  366. set in7_min 5 * 0.95
  367. set in7_max 5 * 1.05
  368. ignore cpu0_vid
  369. set fan4_min 100
  370. set fan1_min 100
  371. ignore fan2
  372. ignore fan3
  373. ignore fan5
  374. ignore in8
  375. ignore intrusion0
  376. label fan1 "fan1"
  377. label fan4 "fan2"
  378. label temp1 "MB"
  379. label temp2 "CPU"
  380. set temp2_min 0
  381. set temp2_max 75
  382. set temp1_min 0
  383. set temp1_max 90
  384. set temp1_beep 0.0
  385. label temp1 "VRM Temp"
  386. set temp1_min 0
  387. set temp1_max 65
  388. label temp2 "SB Temp"
  389. label temp3 "CPU Temp"
  390. set temp3_min 0
  391. set temp3_max 65
  392. chip "nvme-pci-0400"
  393. set temp2_max 75
  394. set temp2_min 20
  395. set temp3_max 75
  396. set temp3_min 20
  397. EOF
  398. chmod 644 /tmp/sensors3.conf
  399. sudo cp /tmp/sensors3.conf /etc/
  400. sudo sensors -s
  401. sensors
  402. sudo apt install ethtool -y
  403. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{printf $2a}' | cut -d ' ' -f2)
  404. sudo ethtool --change $iface wol g
  405. cat <<'EOF'>> /tmp/wakemeup.sh
  406. #!/bin/bash
  407. set -e
  408. if ! [ -x "$(command -v etherwake)" ];then sudo apt-get install etherwake -y;fi
  409. clear
  410. echo -e "$(tput setaf 10)Wake On Lan v1.0:$(tput sgr0)"
  411. PS3="Select : "
  412. items=("Nzxt" "Garage" "Blade")
  413. select item in "${items[@]}" Quit
  414. do
  415. case $REPLY in
  416. 1) sudo etherwake -i enp5s0 E0:D5:5E:2D:9E:CB ; break;;
  417. 2) sudo etherwake -i enp5s0 58:11:22:CD:FC:7A ; break;;
  418. 3) sudo etherwake -i enp5s0 78:AC:44:57:3C:50 ; break;;
  419. $((${#items[@]}+1))) echo "We're done!"; break 2;;
  420. *) echo "Ooops - unknown choice $REPLY"; break;
  421. esac
  422. done
  423. echo -e ""
  424. EOF
  425. sudo chmod +x /tmp/wakemeup.sh
  426. sudo cp /tmp/wakemeup.sh /usr/local/bin
  427. echo "Done."
  428. echo -e "$(tput setaf 10)\nVnc init:$(tput sgr0)"
  429. sudo update-rc.d vncserver defaults
  430. echo "Done."
  431. echo -e "$(tput setaf 10)\nOpening ports:$(tput sgr0)"
  432. sudo ufw allow 8333 >/dev/null
  433. sudo ufw allow 22 >/dev/null
  434. sudo ufw allow 5900 >/dev/null
  435. sudo ufw allow 10000 >/dev/null
  436. sudo ufw allow 139 >/dev/null
  437. sudo ufw allow 5901 >/dev/null
  438. sudo ufw allow 5902 >/dev/null
  439. sudo ufw allow 445 >/dev/null
  440. sudo ufw allow 1337 >/dev/null
  441. sudo ufw allow 1447 >/dev/null
  442. echo "Done."
  443. echo -e "$(tput setaf 10)\nBashrc mod:$(tput sgr0)"
  444. if [ $Cuda = "YES" ]
  445. then
  446. if ! grep "#mod for cuda" /home/wareck/.bashrc >/dev/null
  447. then
  448. echo '#mod for cuda' >>/home/wareck/.bashrc
  449. echo 'export PATH=/usr/local/cuda-12.3/bin/:$PATH'>>/home/wareck/.bashrc
  450. echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64:$LD_LIBRARY_PATH'>>/home/wareck/.bashrc
  451. echo '' >>/home/wareck/.bashrc
  452. fi
  453. fi
  454. if ! grep "#mod for tightvncserver" /home/wareck/.bashrc >/dev/null
  455. then
  456. echo '#mod for tightvncserver' >>/home/wareck/.bashrc
  457. echo 'cd ~' >>/home/wareck/.bashrc
  458. fi
  459. echo "Done."
  460. echo -e "$(tput setaf 10)\nDisable IPv6:$(tput sgr0)"
  461. if ! grep "ipv6.disable=1" /etc/default/grub >/dev/null
  462. then
  463. sed -i -e "s/quiet splash/quiet splash ipv6.disable=1/g" /etc/default/grub
  464. sed -i -e "s/GRUB_CMDLINE_LINUX=\"/GRUB_CMDLINE_LINUX=\"ipv6.disable=1 acpi_enforce_resources=lax/g" /etc/default/grub
  465. sudo update-grub2
  466. fi
  467. sudo chown -R wareck:wareck /home/wareck/miners/xmr*
  468. sudo chown -R wareck:wareck /home/wareck/miners/cgminer*
  469. sudo apt-get remove light-locker* -y
  470. if [ ! -d /home/wareck/.config/lxpanel/LXDE/panels ]
  471. then
  472. mkdir /home/wareck/.config/lxpanel
  473. mkdir /home/wareck/.config/lxpanel/LXDE
  474. mkdir /home/wareck/.config/lxpanel/LXDE/panels
  475. fi
  476. sudo cp /home/wareck/Build_Cube/pack/panel /home/wareck/.config/lxpanel/LXDE/panels/panel
  477. sudo chmod 777 /home/wareck/.config/lxpanel/LXDE/panels/panel
  478. if [ ! -d /home/wareck/.config/lxterminal ]
  479. then
  480. mkdir /home/wareck/.config/lxterminal
  481. fi
  482. sudo cp /home/wareck/Build_Cube/pack/lxterminal.conf /home/wareck/.config/lxterminal/
  483. sudo chmod 777 /home/wareck/.config/lxterminal/lxterminal.conf
  484. echo "Done."
  485. echo "passe=4" >/home/wareck/.ipass
  486. decompte_
  487. }
  488. function printer_ {
  489. if [ ! -d /usr/local/share/foomatic/ ]
  490. then
  491. if [ ! -d /tmp/foomatic-db/ ]
  492. then
  493. cd /tmp/
  494. echo -e "$(tput setaf 10)\nInstall printers generic drivers:$(tput sgr0)"
  495. git clone https://github.com/OpenPrinting/foomatic-db.git
  496. fi
  497. cd /tmp/foomatic-db
  498. if [ ! -d /usr/local/share/foomatic/ ]
  499. then
  500. ./make_configure
  501. ./configure
  502. sudo make install
  503. echo "Done."
  504. fi
  505. fi
  506. }
  507. function mounting_drives_ {
  508. echo -e "$(tput setaf 10)\nMounting Drives$(tput sgr0)"
  509. if ! findmnt /media/store >/dev/null ; then sudo mount /media/Store ;fi
  510. sudo chmod 777 /media/store
  511. sudo chmod 777 /raid
  512. echo "Done."
  513. }
  514. function cleaning_ {
  515. echo -e "$(tput setaf 10)\nCleaning install files:$(tput sgr0)"
  516. if [ -f /pack2.tar.xz ]; then sudo rm /pack2.tar.xz ;fi
  517. if [ -f /pack3.tar.xz ]; then sudo rm /pack3.tar.xz ;fi
  518. if [ -f /home/wareck/pack1.tar.xz ]; then rm /home/wareck/pack1.tar.xz ;fi
  519. if [ -f /home/wareck/pack2.tar.xz ]; then rm /home/wareck/pack2.tar.xz ;fi
  520. if [ -f /home/wareck/pack3.tar.xz ]; then rm /home/wareck/pack3.tar.xz ;fi
  521. if [ -f /home/wareck/xmrig.tar.xz ]; then rm /home/wareck/xmrig.tar.xz ;fi
  522. if [ -f /home/wareck/gpu-miners.tar.xz ]; then rm /home/wareck/gpu-miners.tar.xz;fi
  523. if [ -r /home/wareck/Music ]; then sudo rm -r -f /home/wareck/Music ;fi
  524. if [ -r /home/wareck/Public ]; then sudo rm -r -f /home/wareck/Public ;fi
  525. if [ -r /home/wareck/Templates ]; then sudo rm -r -f /home/wareck/Templates ;fi
  526. if [ -r /home/wareck/Vidéos ]; then sudo rm -r -f /home/wareck/Vidéos ;fi
  527. if [ -f /home/wareck/NVIDIA-Linux-x86_64-470.74.run ]; then rm /home/wareck/NVIDIA-Linux-x86_64-470.74.run ;fi
  528. 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
  529. if [ -f /home/wareck/.ipass ]; then rm /home/wareck/.ipass ;fi
  530. if [ -f /usr/local/bin/zap ]; then sudo rm /usr/local/bin/zap* ;fi
  531. if [ -f /home/wareck/.config/autostart/install_os.desktop ];then sudo rm /home/wareck/.config/autostart/install_os.desktop;fi
  532. if [ -f /home/wareck/.config/autostart/zappy.desktop ];then sudo rm /home/wareck/.config/autostart/zappy.desktop;fi
  533. if [ -r /lib/modules/5.15.0-60-generic ]; then sudo rm -r /lib/modules/5.15.0-60-generic ;fi
  534. if [ -r /lib/modules/5.15.0-46-generic ]; then sudo rm -r /lib/modules/5.15.0-46-generic ;fi
  535. if [ -r /lib/modules/5.15.0-70-generic ]; then sudo rm -r /lib/modules/5.15.0-70-generic ;fi
  536. cd /home/wareck/Build_Cube/pack
  537. sudo chown -R wareck:wareck /home/wareck/miners
  538. sudo chmod -R 775 /home/wareck/miners
  539. ./clean.sh
  540. echo -e "Done. \n"
  541. echo `date` "install/update" >/home/wareck/.buildcube
  542. sudo apt-get autoremove -y
  543. sleep 1
  544. }
  545. function autoroot_ {
  546. if ! grep "#color putty" ~/.bashrc >/dev/null
  547. then
  548. echo "#color putty" >> ~/.bashrc
  549. echo "export TERM=xterm-256color" >> ~/.bashrc
  550. fi
  551. if [ ! -d /home/wareck/.config/autostart ]
  552. then
  553. echo -e "$(tput setaf 10)\nInit install & autostart:$(tput sgr0)"
  554. mkdir /home/wareck/.config/autostart
  555. echo -e "Done."
  556. sleep 1
  557. fi
  558. if [ ! -f /home/wareck/.config/autostart/install_os.desktop ]
  559. then
  560. cat <<'EOF'>> /home/wareck/.config/autostart/install_os.desktop
  561. [Desktop Entry]
  562. # VERSION=3.36.2
  563. Name=Terminal
  564. Comment=Use the command line
  565. Keywords=shell;prompt;command;commandline;cmd;
  566. TryExec=gnome-terminal
  567. Exec=gnome-terminal -- bash -c "sudo /home/wareck/Build_Cube/edge.sh; exec bash"
  568. Icon=org.gnome.Terminal
  569. Type=Application
  570. Categories=GNOME;GTK;System;TerminalEmulator;
  571. StartupNotify=true
  572. X-GNOME-SingleWindow=false
  573. OnlyShowIn=GNOME;Unity;
  574. Actions=new-window;preferences;
  575. X-Ubuntu-Gettext-Domain=gnome-terminal
  576. [Desktop Action new-window]
  577. Name=New Window
  578. Exec=gnome-terminal --window
  579. [Desktop Action preferences]
  580. Name=Preferences
  581. Exec=gnome-terminal --preferences
  582. EOF
  583. chmod +x /home/wareck/.config/autostart/install_os.desktop
  584. fi
  585. if [ ! -f /home/wareck/.config/autostart/zappy.desktop ]
  586. then
  587. cat <<'EOF'>> /home/wareck/.config/autostart/zappy.desktop
  588. [Desktop Entry]
  589. # VERSION=3.36.2
  590. Name=Terminal
  591. Comment=Use the command line
  592. Keywords=shell;prompt;command;commandline;cmd;
  593. TryExec=gnome-terminal
  594. Exec=gnome-terminal -- bash -c "/usr/local/bin/zap"
  595. Icon=org.gnome.Terminal
  596. Type=Application
  597. Categories=GNOME;GTK;System;TerminalEmulator;
  598. StartupNotify=true
  599. X-GNOME-SingleWindow=false
  600. OnlyShowIn=GNOME;Unity;
  601. Actions=new-window;preferences;
  602. X-Ubuntu-Gettext-Domain=gnome-terminal
  603. [Desktop Action new-window]
  604. Name=New Window
  605. Exec=gnome-terminal --window
  606. [Desktop Action preferences]
  607. Name=Preferences
  608. Exec=gnome-terminal --preferences
  609. EOF
  610. chmod +x /home/wareck/.config/autostart/zappy.desktop
  611. fi
  612. if ! grep "wareck" /etc/sudoers >/dev/null
  613. then
  614. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  615. fi
  616. if [ $passe="2" ]
  617. then
  618. echo -e "$(tput setaf 10)\nUpdate and install packages:$(tput sgr0)"
  619. sudo apt-get update
  620. sudo apt-get install lxde lxde-icon-theme -y
  621. sleep 1
  622. fi
  623. }
  624. function remove_screensaver {
  625. #remove screensaver
  626. cat <<EOF>> autostart
  627. @lxpanel --profile LXDE
  628. @pcmanfm --desktop --profile LXDE
  629. EOF
  630. sudo chmod 744 autostart
  631. sudo cp autostart /etc/xdg/lxsession/LXDE/
  632. sudo cp autostart /home/wareck/.config/lxsession/LXDE/
  633. sudo rm autostart
  634. sudo apt-get remove xscreensaver xscreensaver-data -y
  635. }
  636. function cmake_ {
  637. pids=""
  638. /home/wareck/Build_Cube/options/tools/_cmake.sh rollback & pids="$pids $!"
  639. wait $pids
  640. sudo ldconfig
  641. }
  642. function watchdog_ {
  643. pids=""
  644. /home/wareck/Build_Cube/options/watchdog.sh ext & pids="$pids $!"
  645. wait $pids
  646. }
  647. function wol_ {
  648. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{printf $2a}' | cut -d ' ' -f2)
  649. ether=$(which ethtool)
  650. echo "[Unit]" >>/tmp/wol.service
  651. echo "Description=Enable Wake On Lan" >>/tmp/wol.service
  652. echo "" >>/tmp/wol.service
  653. echo "[Service]" >>/tmp/wol.service
  654. echo "Type=oneshot" >>/tmp/wol.service
  655. echo "ExecStart = $ether --change $iface wol g" >>/tmp/wol.service
  656. echo "" >>/tmp/wol.service
  657. echo "[Install]" >>/tmp/wol.service
  658. echo "WantedBy=basic.target" >>/tmp/wol.service
  659. sudo cp /tmp/wol.service /etc/systemd/system/wol.service
  660. sudo systemctl daemon-reload >/dev/null
  661. sudo systemctl enable wol.service >/dev/null
  662. sudo systemctl start wol.service >/dev/null
  663. sleep 2
  664. clear
  665. }
  666. intro_
  667. case $passe in
  668. 1)
  669. watchdog_
  670. autoroot_
  671. ubuntu_version_check
  672. update_
  673. kernel_check_
  674. nvidia_driver_
  675. ;;
  676. 2)
  677. nvidia_driver_
  678. update_
  679. ;;
  680. 3)
  681. download_packs_
  682. printer_
  683. build_miners_
  684. configure_
  685. ;;
  686. 4)
  687. mounting_drives_
  688. cleaning_
  689. remove_screensaver
  690. clear
  691. wol_
  692. dynmotd
  693. ;;
  694. *) ;;
  695. esac
  696. echo -e "$(tput setaf 10)\nEnd of script:$(tput sgr0) \n"
  697. echo -e "$(tput setaf 7)Need to install webmin manually (reboot required)$(tput sgr0)"
  698. echo -e "$(tput setaf 7)after install webmin, reboot is required $(tput sgr0)"
  699. echo -e ""