build_cube.sh 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  1. #!/bin/bash
  2. set -e
  3. Version=18.3.3
  4. Cuda=YES
  5. kernel_custom=YES
  6. Miners=Yes
  7. Webmin="webmin-2.105"
  8. kernel_dkms="5.15.0-71-generic"
  9. driver=NVIDIA
  10. if (( $EUID != 0 )); then
  11. echo -e "$(tput setaf 11)This must be run as root. Try 'sudo $0'.$(tput sgr0)"
  12. exit 1
  13. fi
  14. clear
  15. export TERM=xterm-256color
  16. Cuda=${Cuda^^}
  17. kernel_custom=${kernel_custom^^}
  18. driver=${driver^^}
  19. Miners=${Miners^^}
  20. function ubuntu_version_check {
  21. if [[ $(lsb_release -rs) == "20.04" ]]
  22. then
  23. Ubuntu_version="20.04.5"
  24. else
  25. echo "Non-compatible version"
  26. exit 0
  27. fi
  28. }
  29. function print_centered {
  30. [[ $# == 0 ]] && return 1
  31. declare -i TERM_COLS="$(tput cols)"
  32. declare -i str_len="${#1}"
  33. [[ $str_len -ge $TERM_COLS ]] && {
  34. echo "$1";
  35. return 0;
  36. }
  37. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  38. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  39. filler=""
  40. for (( i = 0; i < filler_len; i++ )); do
  41. filler="${filler}${ch}"
  42. done
  43. printf "%s%s%s" "$filler" "$1" "$filler"
  44. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  45. printf "\n"
  46. return 0
  47. }
  48. function decompte_ {
  49. echo -e "$(tput setaf 10)\nReboot in 10 seconds (CRTL+C to abord):$(tput sgr0)"
  50. for i in {9..0}
  51. do
  52. echo -e -n "$i "
  53. sleep 1
  54. done
  55. echo ""
  56. sudo reboot
  57. }
  58. function intro_ {
  59. print_centered "$(tput setaf 5)"
  60. print_centered " ██████╗██╗ ██╗██████╗ ███████╗"
  61. print_centered "██╔════╝██║ ██║██╔══██╗██╔════╝"
  62. print_centered "██║ ██║ ██║██████╔╝█████╗ "
  63. print_centered "██║ ██║ ██║██╔══██╗██╔══╝ "
  64. print_centered "╚██████╗╚██████╔╝██████╔╝███████╗"
  65. print_centered " ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝"
  66. echo -n "$(tput sgr0)"
  67. print_centered "Cube Server installation script v$Version"
  68. print_centered "Ubuntu version 20.04.6"
  69. if [ $Cuda = "YES" ]
  70. then
  71. print_centered "CUDA"
  72. fi
  73. sleep 3
  74. }
  75. function update_ {
  76. if [ -f /home/wareck/.pass2 ] && [ ! -f /home/wareck/.pass3 ] && [ ! -f /home/wareck/.pass4 ]
  77. then
  78. echo -e "$(tput setaf 10)\nUpdate and install packages:$(tput sgr0)"
  79. sudo apt-get update
  80. echo -e ""
  81. sudo apt-get install lxde lxde-icon-theme -y
  82. echo -e ""
  83. sudo apt-get install samba cifs-utils mdadm git build-essential libtool pkg-config automake autoconf ethtool net-tools openvpn filezilla \
  84. tasksel lzma-dev lzma cmake libuv1-dev libssl-dev msr-tools tightvncserver lm-sensors openssh-server xfsprogs -y
  85. echo -e ""
  86. sudo apt-get install zstd pixz pbzip2 pigz btrfs-progs gparted gpart gnome-remote-desktop libcanberra-gtk-module \
  87. ctorrent libcurl4-openssl-dev bison byacc screen libudev-dev libjansson-dev libncurses5-dev libmicrohttpd-dev curl nvme-cli -y
  88. echo -e ""
  89. sudo apt-get install libglib2.0-dev libgtk2.0-dev libsensors4-dev htop vlc locate cmake -y
  90. echo -e ""
  91. if [ $Cuda = "YES" ]
  92. then
  93. echo -e "$(tput setaf 10)\nInstall Cuda packages:$(tput sgr0)"
  94. sudo apt-get install libgmp-dev libnuma-dev cmake libuv1-dev nvidia-cuda-dev libmicrohttpd-dev gcc-8 g++-8 nvidia-cuda-toolkit -y
  95. fi
  96. echo -e "Done."
  97. fi
  98. }
  99. function kernel_check_ {
  100. unamestr=$(uname -r)
  101. case $kernel_custom in
  102. NO)
  103. if [[ "$unamestr" == '5.15.0-69-generic' ]]
  104. then
  105. echo -e "\n$(tput setaf 10)DKMS Kernel install :$(tput sgr0)"
  106. sudo rm /boot/config-5.15*
  107. sudo rm /boot/initrd.img-5.15*
  108. sudo rm /boot/System.map-5.15*
  109. sudo rm /boot/vmlinuz-5.15*
  110. sudo apt-get install linux-image-5.4.0-54-generic linux-headers-5.4.0-54-generic linux-modules-extra-5.4.0-54-generic htop -y
  111. sudo update-grub2
  112. sudo apt-mark hold linux-image-5.4.0-54-generic linux-headers-5.4.0-54-generic linux-modules-extra-5.4.0-54-generic
  113. autoroot_
  114. decompte_
  115. fi
  116. if [[ "$unamestr" == '5.4.0-139-generic' ]]
  117. then
  118. sudo rm /boot/config-5.4.0-139-generic | true
  119. sudo rm /boot/System.map-5.4.0-139-generic | true
  120. sudo rm /boot/initrd.img-5.4.0-139-generic | true
  121. sudo rm /boot/vmlinuz-5.4.0-139-generic | true
  122. sudo update-grub2
  123. sudo apt-mark hold linux-image-$kernel_dkms linux-headers-$kernel_dkms linux-modules-extra-$kernel_dkms
  124. autoroot_
  125. decompte_
  126. fi
  127. ;;
  128. YES)
  129. if [ -f /tmp/ksource.txt ]; then rm /tmp/ksource.txt;fi
  130. wget -c -q http://192.168.1.8:3000/wareck/custom_kernel/raw/master/ksource.txt -O /tmp/ksource.txt
  131. source /tmp/ksource.txt
  132. if ! [[ "$unamestr" == $KLversion ]]
  133. then
  134. echo -e "\n$(tput setaf 10)Custom kernel install $(tput setaf 9)$KLversion$(tput setaf 10) (fix DKMS/WOL) :$(tput sgr0)"
  135. cd /tmp/
  136. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/custom_kernel/$kernel_version
  137. chmod +x $kernel_version
  138. sudo ./$kernel_version
  139. nvidia_driver_
  140. autoroot_
  141. decompte_
  142. fi
  143. ;;
  144. esac
  145. }
  146. function nvidia_driver_ {
  147. if ! [ -f /home/wareck/.pass1 ]
  148. then
  149. if ! [ -f /etc/modprobe.d/blacklist-nvidia-nouveau.conf ]
  150. then
  151. echo "Blacklist nvidia-nouveau driver..."
  152. echo "System will reboot"
  153. sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
  154. sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
  155. fi
  156. case $Cuda in
  157. NO)
  158. sudo apt-get install build-essential libglvnd-dev cmake -y
  159. ;;
  160. YES)
  161. sudo apt-get install build-essential libglvnd-dev cmake libhugetlbfs-dev libc-dev libc6-dev g++ -y
  162. ;;
  163. *)
  164. ;;
  165. esac
  166. #sudo update-initramfs -u
  167. touch /home/wareck/.pass1
  168. decompte_
  169. fi
  170. if ! [ -f /home/wareck/.pass2 ]
  171. then
  172. sleep 1
  173. case $Cuda in
  174. NO)
  175. echo -e "$(tput setaf 10)\nInstall NVIDIA GTX1080 Drivers :$(tput sgr0)"
  176. sleep 3
  177. sudo apt-get install nvidia-driver-525 -y
  178. touch /home/wareck/.pass2
  179. decompte_
  180. ;;
  181. YES)
  182. echo -e "$(tput setaf 10)\nInstall CUDA Drivers :$(tput sgr0)"
  183. cd /home/wareck/
  184. echo -e "Download MegaDownload:"
  185. git clone https://github.com/wareck/megadown.git
  186. sudo cp /home/wareck/megadown/megadown /usr/local/bin/megadown
  187. sudo rm -r /home/wareck/megadown
  188. #megadown https://mega.nz/file/r0wwnZCJ#27WWRMwSsGYXiMUHf2OgcGYp2O2itChsBxcK9znmr5E
  189. #chmod +x cuda_11.8.0_520.61.05_linux.run
  190. #sudo ./cuda_11.8.0_520.61.05_linux.run
  191. #sudo rm cuda_11.8.0_520.61.05_linux.run
  192. #wget -c https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux.run
  193. #megadown https://mega.nz/file/u9h1wbYL#QuHtEpCErWXDFjjMVFTK9QzcAI5SrsgTMbx6DfFJT2k
  194. #wget https://developer.download.nvidia.com/compute/cuda/12.3.0/local_installers/cuda_12.3.0_545.23.06_linux.run
  195. wget https://developer.download.nvidia.com/compute/cuda/12.3.1/local_installers/cuda_12.3.1_545.23.08_linux.run
  196. chmod +x cuda_12.3.1_545.23.08_linux.run
  197. sudo ./cuda_12.3.1_545.23.08_linux.run --silent --driver --toolkit
  198. sudo rm cuda_12.3.1_545.23.08_linux.run
  199. touch /home/wareck/.pass2
  200. decompte_
  201. ;;
  202. esac
  203. fi
  204. }
  205. function download_packs_ {
  206. if [ ! -f /home/wareck/.pass3 ]
  207. then
  208. echo -e "$(tput setaf 10)\nDownload complement packs:$(tput sgr0)"
  209. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/cgminer.conf -O /home/wareck/Build_Cube/pack/cgminer.conf
  210. 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
  211. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/gerbera.tar.xz -O /home/wareck/Build_Cube/pack/gerbera.tar.xz
  212. 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
  213. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/$Webmin.tar.xz -O /home/wareck/Build_Cube/pack/$Webmin.tar.xz
  214. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/xmrig.tar.xz -O /home/wareck/Build_Cube/pack/xmrig.tar.xz
  215. 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
  216. 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
  217. cp /home/wareck/Build_Cube/pack/gpu-miners.tar.xz /home/wareck
  218. cp /home/wareck/Build_Cube/pack/pack1.tar.xz /home/wareck
  219. cp /home/wareck/Build_Cube/pack/pack2.tar.xz /home/wareck
  220. cp /home/wareck/Build_Cube/pack/pack3.tar.xz /home/wareck
  221. cp /home/wareck/Build_Cube/pack/xmrig.tar.xz /home/wareck
  222. cp /home/wareck/Build_Cube/pack/start_cgminer.tar.xz /home/wareck
  223. echo "Done."
  224. if [ ! -d /home/wareck/$Webmin ]
  225. then
  226. cp /home/wareck/Build_Cube/pack/$Webmin.tar.xz /home/wareck/
  227. cd /home/wareck/
  228. echo -e "$(tput setaf 10)\nWebmin uncompress:$(tput sgr0)"
  229. tar xfJ $Webmin.tar.xz
  230. rm $Webmin.tar.xz
  231. echo -e "Done"
  232. fi
  233. echo -e "$(tput setaf 10)\nDownloading miners:$(tput sgr0)"
  234. cd /home/wareck
  235. if ! [ -d miners ]; then mkdir -p miners;fi
  236. cd /home/wareck/miners
  237. if ! [ -d xmrig ]
  238. then
  239. git clone https://github.com/xmrig/xmrig.git
  240. echo -e ""
  241. fi
  242. if ! [ -d xmr-stak ]
  243. then
  244. git clone https://github.com/fireice-uk/xmr-stak.git
  245. echo -e ""
  246. fi
  247. if ! [ -d xmr-stak-rx ]
  248. then
  249. git clone https://github.com/fireice-uk/xmr-stak.git -b xmr-stak-rx xmr-stak-rx
  250. echo -e ""
  251. fi
  252. if ! [ -d cgminer-gekko ]
  253. then
  254. git clone https://github.com/wareck/cgminer-gekko.git
  255. echo -e ""
  256. fi
  257. if ! [ -d cgminer-lketc ]
  258. then
  259. git clone https://github.com/wareck/cgminer-lketc.git
  260. fi
  261. fi
  262. echo "Done."
  263. }
  264. function build_miners_ {
  265. if [ ! -f /home/wareck/.pass3 ]
  266. then
  267. cmake_ #check cmake version
  268. cd /home/wareck
  269. tar xfJ gpu-miners.tar.xz
  270. cd /home/wareck/miners
  271. echo -e "$(tput setaf 10)\nBuild Cgminer-gekko:$(tput sgr0)"
  272. cd cgminer-gekko
  273. sudo usermod -a -G dialout,plugdev wareck
  274. sudo cp 01-cgminer.rules /etc/udev/rules.d/
  275. CFLAGS="-O2 -march=native" ./autogen.sh
  276. ./configure --enable-gekko
  277. make -j$((`nproc`+1))
  278. tar xfJ /home/wareck/start_cgminer.tar.xz
  279. rm /home/wareck/start_cgminer.tar.xz
  280. cd ..
  281. cat <<'EOF'>> /tmp/cgminer
  282. #!/bin/sh -e
  283. ### BEGIN INIT INFO
  284. # Provides: cgminer
  285. # Required-Start: networking
  286. # Default-Start: 3 4 5
  287. # Default-Stop: 0 6
  288. ### END INIT INFO
  289. case "$1" in
  290. start)
  291. cd /home/wareck/miners/cgminer-gekko/
  292. su wareck -c "screen -dmS cgminer /home/wareck/miners/cgminer-gekko/cgminer"
  293. ;;
  294. stop)
  295. sudo killall -9 cgminer | true
  296. ;;
  297. *)
  298. echo "Usage: /etc/init.d/cgminer {start|stop}"
  299. exit 1
  300. ;;
  301. esac
  302. exit 0
  303. EOF
  304. chmod +x /tmp/cgminer
  305. sudo cp /tmp/cgminer /etc/init.d/cgminer
  306. sudo update-rc.d cgminer defaults
  307. if ! [ -d /home/wareck/.cgminer ]
  308. then
  309. mkdir /home/wareck/.cgminer
  310. fi
  311. cat <<'EOF'>> /tmp/cgminer.conf
  312. {
  313. "pools" : [
  314. {
  315. "url" : "stratum+tcp://stratum.braiins.com:3333",
  316. "user" : "wareck.gekko",
  317. "pass" : "x"
  318. }
  319. ]
  320. ,
  321. "api-description" : "cgminer 4.12.0-wrk",
  322. "api-mcast-addr" : "224.0.0.75",
  323. "api-mcast-code" : "FTW",
  324. "api-mcast-des" : "",
  325. "api-mcast-port" : "4028",
  326. "api-port" : "4028",
  327. "api-host" : "0.0.0.0",
  328. "gekko-lowboost" : true,
  329. "gekko-2pac-freq" : "155.0",
  330. "gekko-compac-freq" : "150.0",
  331. "gekko-tune-down" : "95.0",
  332. "gekko-tune-up" : "97.0",
  333. "gekko-wait-factor" : "0.5",
  334. "gekko-bauddiv" : "0",
  335. "gekko-newpac-freq" : "100",
  336. "gekko-start-freq" : "100",
  337. "gekko-step-freq" : "6.2",
  338. "gekko-step-delay" : "15",
  339. "gekko-tune2" : "0",
  340. "fallback-time" : "120",
  341. "hotplug" : "5",
  342. "log" : "5",
  343. "shares" : "0",
  344. "suggest-diff" : "0"
  345. }
  346. EOF
  347. cp /tmp/cgminer.conf /home/wareck/.cgminer/
  348. echo "Done."
  349. cd /home/wareck/miners
  350. echo -e "$(tput setaf 10)\nBuild Cgminer-lketc:$(tput sgr0)"
  351. cd cgminer-lketc
  352. CFLAGS="-O2 -march=native" ./autogen.sh
  353. ./configure
  354. make -j$((`nproc`+1))
  355. cd ..
  356. echo "Done."
  357. echo -e "$(tput setaf 10)\nUncompress xmr files:$(tput sgr0)"
  358. tar xfJ /home/wareck/xmrig.tar.xz --checkpoint=.100
  359. echo "Done."
  360. echo -n -e "\n"
  361. echo -e "$(tput setaf 10)\nBuild xmrig:$(tput sgr0)"
  362. cd xmrig
  363. git config --global --add safe.directory /home/wareck/miners/xmrig
  364. git pull
  365. sed -i "s/kDefaultDonateLevel = 5;/kDefaultDonateLevel = 0;/g" src/donate.h
  366. sed -i "s/kMinimumDonateLevel = 1;/kMinimumDonateLevel = 0;/g" src/donate.h
  367. wget -c https://download.open-mpi.org/release/hwloc/v2.7/hwloc-2.7.1.tar.bz2
  368. tar xfj hwloc-2.7.1.tar.bz2 --checkpoint=.100
  369. cd hwloc-2.7.1
  370. ./configure
  371. make -j$((`nproc`+1))
  372. sudo make install
  373. cd ..
  374. sudo ldconfig
  375. cd build
  376. cmake ..
  377. make -j$((`nproc`+1))
  378. cd ..
  379. cd ..
  380. echo "Done."
  381. #echo -e "$(tput setaf 10)\nBuild xmrig-upx:$(tput sgr0)"
  382. #cd xmrig-upx
  383. #git config --global --add safe.directory /home/wareck/miners/xmrig-upx
  384. #git pull
  385. #sed -i "s/kDefaultDonateLevel = 5;/kDefaultDonateLevel = 0;/g" src/donate.h
  386. #sed -i "s/kMinimumDonateLevel = 1;/kMinimumDonateLevel = 0;/g" src/donate.h
  387. #cd build
  388. #cmake .. -DWITH_HTTPD=OFF
  389. #make -j$((`nproc`+1))
  390. #cd ..
  391. #cd ..
  392. #echo "Done."
  393. rm -r -f xmrig-upx
  394. echo -e "$(tput setaf 10)\nBuild xmr-stak-rx:$(tput sgr0)"
  395. cd xmr-stak-rx
  396. git config --global --add safe.directory /home/wareck/miners/xmr-stak-rx
  397. git pull
  398. cd build
  399. cmake ..
  400. make -j$((`nproc`+1))
  401. cd ..
  402. cd ..
  403. echo "Done."
  404. echo -e "$(tput setaf 10)\nBuild xmr-stak:$(tput sgr0)"
  405. cd xmr-stak
  406. if ! [ -d build ];then mkdir build ;fi
  407. git config --global --add safe.directory /home/wareck/miners/xmr-stak
  408. git pull
  409. cd build
  410. cmake .. -DOpenCL_ENABLE=OFF -DCUDA_ENABLE=OFF
  411. make -j$((`nproc`+1))
  412. cd ..
  413. cd ..
  414. echo "Done."
  415. if [ $Cuda = "YES" ]
  416. then
  417. echo -e "$(tput setaf 10)\nBuild xmrig-cuda:$(tput sgr0)"
  418. git clone https://github.com/xmrig/xmrig-nvidia.git
  419. cd xmrig-nvidia
  420. mkdir build
  421. cd build
  422. cmake .. -DCMAKE_C_COMPILER=$(which gcc-8) -DCMAKE_CXX_COMPILER=$(which g++-8)
  423. make -j$((`nproc`+1))
  424. fi
  425. echo "Done"
  426. touch /home/wareck/.pass3
  427. fi
  428. sudo chmod -R 775 /home/wareck/miners
  429. }
  430. function configure_ {
  431. if [ ! -f /home/wareck/.pass4 ]
  432. then
  433. echo -e "$(tput setaf 10)\nlxPanel sensors:$(tput sgr0)"
  434. cd /home/wareck
  435. if ! [ -d sensors-lxpanel-plugin ]
  436. then
  437. git clone https://github.com/danamlund/sensors-lxpanel-plugin.git
  438. fi
  439. cd /home/wareck
  440. cd sensors-lxpanel-plugin
  441. make
  442. sudo make install
  443. sudo rm -r /home/wareck/sensors-lxpanel-plugin
  444. echo "Done."
  445. echo -e "$(tput setaf 10)\nConfig files:$(tput sgr0)"
  446. cd /home/wareck/
  447. zip="['firefox.desktop', 'thunderbird.desktop', 'org.remmina.Remmina.desktop', 'filezilla.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Terminal.desktop']"
  448. cat <<'EOF'>> zap
  449. #!/bin/bash
  450. gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 32
  451. gsettings set org.gnome.desktop.background picture-uri /home/wareck/Images/mr-robot-wallpapers.jpg
  452. gsettings set org.gnome.shell favorite-apps "XXX"
  453. #su wareck -c 'gsettings set org.gnome.shell.extensions.dash-to-dock show-mounts false'
  454. dconf load /org/gnome/terminal/ < /usr/local/bin/zap2
  455. EOF
  456. sed -i "s/XXX/$zip/g" zap
  457. UUID=$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d \')
  458. cat <<'EOF'>> zap2
  459. [legacy/profiles:/:XXX]
  460. default-size-columns=110
  461. font='Monospace 9'
  462. use-system-font=false
  463. use-theme-colors=false
  464. EOF
  465. sed -i "s/XXX/$UUID/g" zap2
  466. chmod +x zap
  467. sudo cp zap /usr/local/bin
  468. sudo cp zap2 /usr/local/bin
  469. sudo rm zap
  470. sudo rm zap2
  471. sleep 1
  472. sudo rm -r -f /etc/update-motd.d/*
  473. tar xfJ pack1.tar.xz --checkpoint=.10
  474. echo -n -e "\n"
  475. sudo cp /home/wareck/pack2.tar.xz /
  476. sudo cp /home/wareck/pack3.tar.xz /
  477. cd /
  478. sudo tar xfJ pack2.tar.xz --checkpoint=.10
  479. sudo tar xfJ pack3.tar.xz --checkpoint=.10
  480. echo -n -e "\n"
  481. cd /home/wareck
  482. #clear
  483. dynmotd
  484. sudo sed -i -e "s/# set constantshow/set constantshow/g" /etc/nanorc
  485. if ! grep "wareck" /etc/sudoers >/dev/null
  486. then
  487. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  488. fi
  489. echo -e "$(tput setaf 10)\nBuild folder and mount drives:$(tput sgr0)"
  490. if ! [ -r /media/Cloud ];then sudo mkdir /media/Cloud && cd / & sudo ln -s /media/Cloud /Cloud ;fi
  491. if ! [ -r /media/Store ];then sudo mkdir /media/Store && cd / & sudo ln -s /media/Store /Store;fi
  492. if ! [ -r /media/Partage ];then sudo mkdir /media/Partage && cd / & sudo ln -s /media/Partage /Partage;fi
  493. if ! [ -r /media/Nas ];then sudo mkdir /media/Nas && cd / & sudo ln -s /media/Nas /Nas;fi
  494. if ! [ -r /raid ];then sudo mkdir /raid;fi
  495. if ! [ -r /farm ];then sudo mkdir /farm;fi
  496. if ! [ -r /farm/farm0 ];then sudo mkdir /farm/farm0;fi
  497. if ! [ -r /farm/farm1 ];then sudo mkdir /farm/farm1;fi
  498. if ! [ -r /farm/farm2 ];then sudo mkdir /farm/farm2;fi
  499. if ! [ -r /farm/farm3 ];then sudo mkdir /farm/farm3;fi
  500. if ! [ -r /farm/farm4 ];then sudo mkdir /farm/farm4;fi
  501. if ! grep "UUID=1df72b63-fca0-45c6-992c-3e2532d5591a /media/Store ext4" /etc/fstab >/dev/null
  502. then
  503. cp /etc/fstab /tmp/fstab
  504. cat <<"EOF">> /tmp/fstab
  505. #ext4
  506. UUID=6fc06d70-1a38-4706-ae83-0a329181b9f7 /media/Cloud ext4 auto,nofail,noatime,rw,user 0 0
  507. UUID=a111c12b-d1b4-441a-9352-b6bbc558184e /media/Partage ext4 auto,nofail,noatime,rw,user 0 0
  508. UUID=1df72b63-fca0-45c6-992c-3e2532d5591a /media/Store ext4 auto,nofail,noatime,rw,user 0 0
  509. #btrfs temporary drives
  510. /dev/md0 /raid btrfs ssd,nodatasum,nobarrier,nodatacow,discard=async,noatime 0 0
  511. #Chia drive
  512. UUID=77a593df-1bdb-4012-8c9e-ce50864b464d /farm/farm0 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  513. UUID=0d145a5a-50b0-456c-8998-549def2f9fc9 /farm/farm1 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  514. UUID=b99c7fa3-827c-4c09-a625-a72aec6c9395 /farm/farm2 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  515. UUID=e583a1e4-f8c8-4c2b-a427-cee854e0b56d /farm/farm3 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  516. UUID=d24c7616-91c2-434c-b21e-8dd70d794e25 /farm/farm4 ext4 auto,nofail,noatime,nodiratime,rw,user 0 0
  517. EOF
  518. sudo cp /tmp/fstab /etc/fstab
  519. fi
  520. sudo rm /etc/hosts
  521. sudo cat <<'EOF'>> /etc/hosts
  522. 127.0.0.1 localhost
  523. 127.0.1.1 cube
  524. 192.168.1.8 miniserver miniserver gogserver.dnsalias.com
  525. 192.168.1.10 nzxt
  526. 192.168.1.11 garage
  527. 192.168.1.12 blade
  528. 192.168.1.254 mafreebox.freebox.fr
  529. 192.168.1.200 node
  530. # The following lines are desirable for IPv6 capable hosts
  531. ::1 ip6-localhost ip6-loopback
  532. fe00::0 ip6-localnet
  533. ff00::0 ip6-mcastprefix
  534. ff02::1 ip6-allnodes
  535. ff02::2 ip6-allrouters
  536. EOF
  537. echo "Done."
  538. echo -e "$(tput setaf 10)\nSensors drivers:$(tput sgr0)"
  539. if ! grep "it87" /etc/modules >/dev/null
  540. then
  541. cp /etc/modules /tmp/modules
  542. cat <<"EOF">> /tmp/modules
  543. # Chip drivers
  544. it87
  545. EOF
  546. sudo cp /tmp/modules /etc/modules
  547. fi
  548. if [ -f /tmp/sensors3.conf ]
  549. then
  550. chmod 777 /tmp/sensors3.conf
  551. rm /tmp/sensors3.conf
  552. fi
  553. cat <<'EOF'>> /tmp/sensors3.conf
  554. chip "it8728-isa-0228"
  555. label in0 "Vcore"
  556. label in1 "Vdram" # "DDR3" in BIOS
  557. label in2 "+3.3V"
  558. label in3 "+5V" # Not in BIOS
  559. label in4 "+12V"
  560. ignore in5 # -12V unused
  561. ignore in6
  562. label in7 "5VSB" # Not in BIOS
  563. label in8 "Vbat" # Not in BIOS
  564. compute in3 @ * (6.8/10+1), @ / (6.8/10+1)
  565. compute in4 @ * 3.963, @ / 3.963
  566. compute in7 @ * (6.8/10+1), @ / (6.8/10+1)
  567. set in0_min 0.825 * 0.95
  568. set in0_max 1.425 * 1.05
  569. set in1_min 1.5 * 0.95
  570. set in1_max 1.5 * 1.05
  571. set in2_min 3.3 * 0.95
  572. set in2_max 3.3 * 1.05
  573. set in3_min 5 * 0.95
  574. set in3_max 5 * 1.05
  575. set in4_min 12 * 0.95
  576. set in4_max 12 * 1.05
  577. set in7_min 5 * 0.95
  578. set in7_max 5 * 1.05
  579. ignore cpu0_vid
  580. set fan4_min 100
  581. set fan1_min 100
  582. ignore fan2
  583. ignore fan3
  584. ignore fan5
  585. ignore in8
  586. ignore intrusion0
  587. label fan1 "fan1"
  588. label fan4 "fan2"
  589. label temp1 "MB"
  590. label temp2 "CPU"
  591. set temp2_min 0
  592. set temp2_max 75
  593. set temp1_min 0
  594. set temp1_max 90
  595. set temp1_beep 0.0
  596. label temp1 "VRM Temp"
  597. set temp1_min 0
  598. set temp1_max 65
  599. label temp2 "SB Temp"
  600. label temp3 "CPU Temp"
  601. set temp3_min 0
  602. set temp3_max 65
  603. chip "nvme-pci-0400"
  604. set temp2_max 75
  605. set temp2_min 20
  606. set temp3_max 75
  607. set temp3_min 20
  608. EOF
  609. chmod 644 /tmp/sensors3.conf
  610. sudo cp /tmp/sensors3.conf /etc/
  611. sudo sensors -s
  612. sensors
  613. sudo apt install ethtool -y
  614. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{print $2a;getline}')
  615. sudo ethtool --change $iface wol g
  616. cat <<'EOF'>> /tmp/wakemeup.sh
  617. #!/bin/bash
  618. set -e
  619. if ! [ -x "$(command -v etherwake)" ];then sudo apt-get install etherwake -y;fi
  620. clear
  621. echo -e "$(tput setaf 10)Wake On Lan v1.0:$(tput sgr0)"
  622. PS3="Select : "
  623. items=("Nzxt" "Garage" "Blade")
  624. select item in "${items[@]}" Quit
  625. do
  626. case $REPLY in
  627. 1) sudo etherwake -i enp5s0 E0:D5:5E:2D:9E:CB ; break;;
  628. 2) sudo etherwake -i enp5s0 58:11:22:CD:FC:7A ; break;;
  629. 3) sudo etherwake -i enp5s0 78:AC:44:57:3C:50 ; break;;
  630. $((${#items[@]}+1))) echo "We're done!"; break 2;;
  631. *) echo "Ooops - unknown choice $REPLY"; break;
  632. esac
  633. done
  634. echo -e ""
  635. EOF
  636. sudo chmod +x /tmp/wakemeup.sh
  637. sudo cp /tmp/wakemeup.sh /usr/local/bin
  638. echo "Done."
  639. echo -e "$(tput setaf 10)\nVnc init:$(tput sgr0)"
  640. sudo update-rc.d vncserver defaults
  641. echo "Done."
  642. echo -e "$(tput setaf 10)\nOpening ports:$(tput sgr0)"
  643. sudo ufw allow 8333 >/dev/null
  644. sudo ufw allow 22 >/dev/null
  645. sudo ufw allow 5900 >/dev/null
  646. sudo ufw allow 10000 >/dev/null
  647. sudo ufw allow 139 >/dev/null
  648. sudo ufw allow 5901 >/dev/null
  649. sudo ufw allow 5902 >/dev/null
  650. sudo ufw allow 445 >/dev/null
  651. sudo ufw allow 1337 >/dev/null
  652. sudo ufw allow 1447 >/dev/null
  653. echo "Done."
  654. echo -e "$(tput setaf 10)\nBashrc mod:$(tput sgr0)"
  655. if [ $Cuda = "YES" ]
  656. then
  657. if ! grep "#mod for cuda" /home/wareck/.bashrc >/dev/null
  658. then
  659. echo '#mod for cuda' >>/home/wareck/.bashrc
  660. echo 'export PATH=/usr/local/cuda-12.3/bin/:$PATH'>>/home/wareck/.bashrc
  661. echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64:$LD_LIBRARY_PATH'>>/home/wareck/.bashrc
  662. echo '' >>/home/wareck/.bashrc
  663. fi
  664. fi
  665. if ! grep "#mod for tightvncserver" /home/wareck/.bashrc >/dev/null
  666. then
  667. echo '#mod for tightvncserver' >>/home/wareck/.bashrc
  668. echo 'cd ~' >>/home/wareck/.bashrc
  669. fi
  670. echo "Done."
  671. echo -e "$(tput setaf 10)\nDisable IPv6:$(tput sgr0)"
  672. if ! grep "ipv6.disable=1" /etc/default/grub >/dev/null
  673. then
  674. sed -i -e "s/quiet splash/quiet splash ipv6.disable=1/g" /etc/default/grub
  675. sed -i -e "s/GRUB_CMDLINE_LINUX=\"/GRUB_CMDLINE_LINUX=\"ipv6.disable=1 acpi_enforce_resources=lax/g" /etc/default/grub
  676. sudo update-grub2
  677. fi
  678. sudo chown -R wareck:wareck /home/wareck/miners/xmr*
  679. sudo chown -R wareck:wareck /home/wareck/miners/cgminer*
  680. sudo apt-get remove light-locker* -y
  681. if [ ! -d /home/wareck/.config/lxpanel/LXDE/panels ]
  682. then
  683. mkdir /home/wareck/.config/lxpanel
  684. mkdir /home/wareck/.config/lxpanel/LXDE
  685. mkdir /home/wareck/.config/lxpanel/LXDE/panels
  686. fi
  687. sudo cp /home/wareck/Build_Cube/pack/panel /home/wareck/.config/lxpanel/LXDE/panels/panel
  688. sudo chmod 777 /home/wareck/.config/lxpanel/LXDE/panels/panel
  689. if [ ! -d /home/wareck/.config/lxterminal ]
  690. then
  691. mkdir /home/wareck/.config/lxterminal
  692. fi
  693. sudo cp /home/wareck/Build_Cube/pack/lxterminal.conf /home/wareck/.config/lxterminal/
  694. sudo chmod 777 /home/wareck/.config/lxterminal/lxterminal.conf
  695. echo "Done."
  696. touch /home/wareck/.pass4
  697. decompte_
  698. fi
  699. }
  700. function printer_ {
  701. if [ ! -f /home/wareck/.pass3 ]
  702. then
  703. if [ ! -d /usr/local/share/foomatic/ ]
  704. then
  705. if [ ! -d /tmp/foomatic-db/ ]
  706. then
  707. cd /tmp/
  708. echo -e "$(tput setaf 10)\nInstall printers generic drivers:$(tput sgr0)"
  709. git clone https://github.com/OpenPrinting/foomatic-db.git
  710. fi
  711. cd /tmp/foomatic-db
  712. if [ ! -d /usr/local/share/foomatic/ ]
  713. then
  714. ./make_configure
  715. ./configure
  716. sudo make install
  717. echo "Done."
  718. fi
  719. fi
  720. fi
  721. }
  722. function mounting_drives_ {
  723. if [ ! -f /home/wareck/.pass4 ]
  724. then
  725. echo -e "$(tput setaf 10)\nMounting Drives$(tput sgr0)"
  726. if ! findmnt /media/Partage >/dev/null ; then sudo mount /media/Partage ;fi
  727. if ! findmnt /media/Store >/dev/null ; then sudo mount /media/Store ;fi
  728. if ! findmnt /media/Cloud >/dev/null ; then sudo mount /media/Cloud ;fi
  729. sudo chmod 777 /media/Store
  730. sudo chmod 777 /media/Cloud
  731. sudo chmod 777 /media/Partage
  732. sudo chmod 777 /media/nvme0
  733. sudo chmod 777 /media/nvme1
  734. sudo chmod 777 /media/Nas
  735. echo "Done."
  736. fi
  737. }
  738. function cleaning_ {
  739. if [ -f /home/wareck/.pass4 ]
  740. then
  741. echo -e "$(tput setaf 10)\nCleaning install files:$(tput sgr0)"
  742. if [ -f /pack2.tar.xz ]; then sudo rm /pack2.tar.xz ;fi
  743. if [ -f /pack3.tar.xz ]; then sudo rm /pack3.tar.xz ;fi
  744. if [ -f /home/wareck/pack1.tar.xz ]; then rm /home/wareck/pack1.tar.xz ;fi
  745. if [ -f /home/wareck/pack2.tar.xz ]; then rm /home/wareck/pack2.tar.xz ;fi
  746. if [ -f /home/wareck/pack3.tar.xz ]; then rm /home/wareck/pack3.tar.xz ;fi
  747. if [ -f /home/wareck/xmrig.tar.xz ]; then rm /home/wareck/xmrig.tar.xz ;fi
  748. if [ -f /home/wareck/gpu-miners.tar.xz ]; then rm /home/wareck/gpu-miners.tar.xz;fi
  749. if [ -r /home/wareck/Music ]; then sudo rm -r -f /home/wareck/Music ;fi
  750. if [ -r /home/wareck/Public ]; then sudo rm -r -f /home/wareck/Public ;fi
  751. if [ -r /home/wareck/Templates ]; then sudo rm -r -f /home/wareck/Templates ;fi
  752. if [ -r /home/wareck/Vidéos ]; then sudo rm -r -f /home/wareck/Vidéos ;fi
  753. if [ -f /home/wareck/NVIDIA-Linux-x86_64-470.74.run ]; then rm /home/wareck/NVIDIA-Linux-x86_64-470.74.run ;fi
  754. 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
  755. if [ -f /home/wareck/.pass1 ]; then rm /home/wareck/.pass1 ;fi
  756. if [ -f /home/wareck/.pass2 ]; then rm /home/wareck/.pass2 ;fi
  757. if [ -f /home/wareck/.pass3 ]; then rm /home/wareck/.pass3 ;fi
  758. if [ -f /home/wareck/.pass4 ]; then rm /home/wareck/.pass4 ;fi
  759. if [ -f /usr/local/bin/zap ]; then sudo rm /usr/local/bin/zap* ;fi
  760. if [ -f /home/wareck/.config/autostart/install_os.desktop ];then sudo rm /home/wareck/.config/autostart/install_os.desktop;fi
  761. if [ -f /home/wareck/.config/autostart/zappy.desktop ];then sudo rm /home/wareck/.config/autostart/zappy.desktop;fi
  762. if [ -r /lib/modules/5.15.0-60-generic ]; then sudo rm -r /lib/modules/5.15.0-60-generic ;fi
  763. if [ -r /lib/modules/5.15.0-46-generic ]; then sudo rm -r /lib/modules/5.15.0-46-generic ;fi
  764. if [ -r /lib/modules/5.15.0-70-generic ]; then sudo rm -r /lib/modules/5.15.0-70-generic ;fi
  765. cd /home/wareck/Build_Cube/pack
  766. sudo chown -R wareck:wareck /home/wareck/miners
  767. sudo chmod -R 775 /home/wareck/miners
  768. ./clean.sh
  769. echo -e "Done. \n"
  770. echo `date` "install/update" >/home/wareck/.buildcube
  771. fi
  772. sudo apt-get autoremove -y
  773. sleep 1
  774. }
  775. function autoroot_ {
  776. if ! grep "#color putty" ~/.bashrc >/dev/null
  777. then
  778. echo "#color putty" >> ~/.bashrc
  779. echo "export TERM=xterm-256color" >> ~/.bashrc
  780. fi
  781. if [ ! -d /home/wareck/.config/autostart ]
  782. then
  783. echo -e "$(tput setaf 10)\nInit install & autostart:$(tput sgr0)"
  784. mkdir /home/wareck/.config/autostart
  785. echo -e "Done."
  786. sleep 1
  787. fi
  788. if [ ! -f /home/wareck/.config/autostart/install_os.desktop ]
  789. then
  790. cat <<'EOF'>> /home/wareck/.config/autostart/install_os.desktop
  791. [Desktop Entry]
  792. # VERSION=3.36.2
  793. Name=Terminal
  794. Comment=Use the command line
  795. Keywords=shell;prompt;command;commandline;cmd;
  796. TryExec=gnome-terminal
  797. Exec=gnome-terminal -- bash -c "sudo /home/wareck/Build_Cube/build_cube.sh; exec bash"
  798. Icon=org.gnome.Terminal
  799. Type=Application
  800. Categories=GNOME;GTK;System;TerminalEmulator;
  801. StartupNotify=true
  802. X-GNOME-SingleWindow=false
  803. OnlyShowIn=GNOME;Unity;
  804. Actions=new-window;preferences;
  805. X-Ubuntu-Gettext-Domain=gnome-terminal
  806. [Desktop Action new-window]
  807. Name=New Window
  808. Exec=gnome-terminal --window
  809. [Desktop Action preferences]
  810. Name=Preferences
  811. Exec=gnome-terminal --preferences
  812. EOF
  813. chmod +x /home/wareck/.config/autostart/install_os.desktop
  814. fi
  815. if [ ! -f /home/wareck/.config/autostart/zappy.desktop ]
  816. then
  817. cat <<'EOF'>> /home/wareck/.config/autostart/zappy.desktop
  818. [Desktop Entry]
  819. # VERSION=3.36.2
  820. Name=Terminal
  821. Comment=Use the command line
  822. Keywords=shell;prompt;command;commandline;cmd;
  823. TryExec=gnome-terminal
  824. Exec=gnome-terminal -- bash -c "/usr/local/bin/zap"
  825. Icon=org.gnome.Terminal
  826. Type=Application
  827. Categories=GNOME;GTK;System;TerminalEmulator;
  828. StartupNotify=true
  829. X-GNOME-SingleWindow=false
  830. OnlyShowIn=GNOME;Unity;
  831. Actions=new-window;preferences;
  832. X-Ubuntu-Gettext-Domain=gnome-terminal
  833. [Desktop Action new-window]
  834. Name=New Window
  835. Exec=gnome-terminal --window
  836. [Desktop Action preferences]
  837. Name=Preferences
  838. Exec=gnome-terminal --preferences
  839. EOF
  840. chmod +x /home/wareck/.config/autostart/zappy.desktop
  841. fi
  842. if ! grep "wareck" /etc/sudoers >/dev/null
  843. then
  844. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  845. fi
  846. echo -e "$(tput setaf 10)\nUpdate and install packages:$(tput sgr0)"
  847. sudo apt-get update
  848. sudo apt-get install lxde lxde-icon-theme -y
  849. sleep 1
  850. }
  851. function remove_screensaver {
  852. #remove screensaver
  853. cat <<EOF>> autostart
  854. @lxpanel --profile LXDE
  855. @pcmanfm --desktop --profile LXDE
  856. EOF
  857. sudo chmod 744 autostart
  858. sudo cp autostart /etc/xdg/lxsession/LXDE/
  859. sudo cp autostart /home/wareck/.config/lxsession/LXDE/
  860. sudo rm autostart
  861. sudo apt-get remove xscreensaver xscreensaver-data -y
  862. }
  863. function cmake_ {
  864. pids=""
  865. /home/wareck/Build_Cube/options/tools/_cmake.sh rollback & pids="$pids $!"
  866. wait $pids
  867. sudo ldconfig
  868. }
  869. function watchdog_ {
  870. pids=""
  871. /home/wareck/Build_Cube/options/watchdog.sh ext & pids="$pids $!"
  872. wait $pids
  873. }
  874. function wol_ {
  875. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{print $2a;getline}')
  876. ether=$(which ethtool)
  877. echo "[Unit]" >>/tmp/wol.service
  878. echo "Description=Enable Wake On Lan" >>/tmp/wol.service
  879. echo "" >>/tmp/wol.service
  880. echo "[Service]" >>/tmp/wol.service
  881. echo "Type=oneshot" >>/tmp/wol.service
  882. echo "ExecStart = $ether --change$iface wol g" >>/tmp/wol.service
  883. echo "" >>/tmp/wol.service
  884. echo "[Install]" >>/tmp/wol.service
  885. echo "WantedBy=basic.target" >>/tmp/wol.service
  886. sudo cp /tmp/wol.service /etc/systemd/system/wol.service
  887. sudo systemctl daemon-reload
  888. sudo systemctl enable wol.service
  889. sudo systemctl start wol.service
  890. }
  891. intro_
  892. watchdog_
  893. autoroot_
  894. ubuntu_version_check
  895. update_
  896. kernel_check_
  897. autoroot_
  898. nvidia_driver_
  899. update_
  900. download_packs_
  901. printer_
  902. build_miners_
  903. configure_
  904. mounting_drives_
  905. cleaning_
  906. remove_screensaver
  907. clear
  908. wol_
  909. dynmotd
  910. echo -e "$(tput setaf 10)\nEnd of script:$(tput sgr0) \n"
  911. echo -e "$(tput setaf 7)Need to install webmin manually (reboot required)$(tput sgr0)"
  912. echo -e "$(tput setaf 7)after install webmin, reboot is required $(tput sgr0)"
  913. echo -e ""