build_linux.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. #!/bin/bash
  2. function choice {
  3. if ! [ -f /home/wareck/.pass1 ]
  4. then
  5. echo -e "Linux backup/miner config v3.0 "
  6. echo -e ""
  7. if [ -f ~/b10.conf ]; then rm ~/b10.conf ; fi
  8. PS3='Please enter your choice: '
  9. options=("NVIDIA-RTX-LHR" "NVIDIA-RTX" "NVIDIA-GTX" "AMD" "Quit")
  10. select opt in "${options[@]}"
  11. do
  12. case $opt in
  13. "NVIDIA-RTX-LHR")
  14. Mode="NVIDIALHR"
  15. break
  16. ;;
  17. "NVIDIA-RTX")
  18. Mode="NVIDIARTX"
  19. break
  20. ;;
  21. "NVIDIA-GTX")
  22. Mode="NVIDIAGTX"
  23. break
  24. ;;
  25. "AMD")
  26. Mode="AMD"
  27. break
  28. ;;
  29. "Quit")
  30. exit
  31. break
  32. ;;
  33. *) echo "invalid option $REPLY";;
  34. esac
  35. done
  36. cat <<'EOF'>> ~/b10.conf
  37. Mode=XXX
  38. EOF
  39. sed -i "s/XXX/$Mode/g" ~/b10.conf
  40. touch ~/.pass1
  41. fi
  42. echo -e ""
  43. }
  44. function update_one {
  45. if ! [ -f /home/wareck/.pass2 ]
  46. then
  47. sudo timedatectl set-local-rtc 1 --adjust-system-clock
  48. sudo apt-get update -y
  49. sudo apt-get upgrade -y
  50. sudo apt-get dist-upgrade -y
  51. sudo apt-get install htop python3-pip openssh-server screen wakeonlan -y
  52. wget -c http://folivier.homelinux.org/cube/pack/gpu-miners.tar.xz
  53. cp ~/backup_users_win10/build/miners.tar.xz /home/wareck/
  54. cp ~/backup_users_win10/build/wallpaper.tar.xz /home/wareck/
  55. cp ~/backup_users_win10/build/hashcat.tar.xz /home/wareck/
  56. cd /home/wareck/
  57. tar xvfJ wallpaper.tar.xz
  58. sudo rm wallpaper.tar.xz
  59. touch ~/.pass2
  60. fi
  61. echo -n ""
  62. }
  63. function update_two {
  64. if [ $Mode = "NVIDIAGTX" ]
  65. then
  66. sudo apt install nvidia-cuda-toolkit nvidia-cuda-dev nvidia-driver-470 -y
  67. fi
  68. if [ $Mode = "NVIDIARTX" ]
  69. then
  70. sudo apt install nvidia-cuda-toolkit nvidia-cuda-dev nvidia-driver-510 -y
  71. fi
  72. if [ $Mode = "AMD" ]
  73. then
  74. cd /home/wareck
  75. echo -e ""
  76. echo -e "Install drivers:"
  77. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/amdgpu-install_22.10.2.50102-1_all.deb -O /home/wareck/Build_Cube/pack/amdgpu-install_22.10.2.50102-1_all.deb
  78. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/linux-firmware.tar.xz
  79. tar xvfJ linux-firmware.tar.xz
  80. sudo cp /home/wareck/linux-firmware/amdgpu/* /lib/firmware/amdgpu/
  81. sudo rm -r -f /home/wareck/linux-firmware /home/wareck/linux-firmware.tar.xz
  82. sudo apt-get install /home/wareck/Build_Cube/pack/amdgpu-install_22.10.2.50102-1_all.deb -y
  83. sudo apt-get update
  84. sudo amdgpu-install --opencl=legacy --accept-eula -y
  85. sudo apt install ocl-icd-opencl-dev -y
  86. sudo apt install build-essential cmake git libuv1-dev libssl-dev libhwloc-dev libmicrohttpd-dev lm-sensors htop clinfo -y
  87. fi
  88. sudo apt install samba cifs-utils mdadm git build-essential libtool pkg-config automake autoconf ethtool net-tools openvpn filezilla libuv1-dev libuvc-dev cmake git nmap -y
  89. sudo apt install gcc-8 g++-8 mesa-utils libmicrohttpd-dev libcurl4-openssl-dev lvm2 llvm-dev gparted msr-tools nasm btrfs-progs -y
  90. sudo apt install libssl-dev p7zip-full -y
  91. sudo apt autoremove -y
  92. }
  93. function build_miner {
  94. #gnome-terminal -- htop
  95. cd ~
  96. if [ ! -d miners ];then mkdir miners;fi
  97. cd ~/miners
  98. echo ""
  99. git clone https://github.com/tpruvot/ccminer.git && echo ""
  100. git clone https://github.com/tpruvot/cpuminer-multi.git && echo ""
  101. git clone https://github.com/xmrig/xmrig.git && echo ""
  102. if [ $Mode = "NVIDIAGTX" ] || [ $Mode = "NVIDIARTX" ] || [ $Mode = "NVIDIALHR" ]
  103. then
  104. git clone https://github.com/xmrig/xmrig-nvidia.git && echo ""
  105. fi
  106. git clone https://github.com/uPlexa/xmrig-upx.git && echo ""
  107. git clone https://github.com/fireice-uk/xmr-stak.git && echo ""
  108. git clone https://github.com/fireice-uk/xmr-stak.git -b xmr-stak-rx xmr-stak-rx && echo ""
  109. if [ $Mode = "AMD" ]
  110. then
  111. git clone https://github.com/xmrig/xmrig-amd.git && echo ""
  112. fi
  113. cd ~
  114. tar xvfJ miners.tar.xz
  115. rm miners.tar.xz
  116. cd ~/miners
  117. wget -c https://download.open-mpi.org/release/hwloc/v2.5/hwloc-2.5.0.tar.bz2
  118. tar xvfj hwloc-2.5.0.tar.bz2
  119. cd hwloc-2.5.0
  120. ./configure
  121. make -j$(nproc)
  122. sudo make install
  123. cd ..
  124. rm -r hwloc-2.5.0
  125. rm hwloc-2.5.0.tar.bz2
  126. cd xmrig
  127. cd build
  128. cmake ..
  129. make -j$(nproc)
  130. cd ~/miners
  131. if [ $Mode = "NVIDIAGTX" ] || [ $Mode = "NVIDIARTX" ] || [ $Mode = "NVIDIALHR" ]
  132. then
  133. cd xmrig-nvidia
  134. cd build
  135. cmake .. -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
  136. make -j$(nproc)
  137. fi
  138. cd ~/miners
  139. cd xmrig-upx
  140. cd build
  141. cmake ..
  142. make -j$(nproc)
  143. cd ~/miners
  144. cd xmr-stak
  145. mkdir build
  146. cd build
  147. cmake .. -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
  148. make -j$(nproc)
  149. cd ~/miners
  150. cd cpuminer-multi
  151. ./build.sh
  152. if [ $Mode = "AMD" ]
  153. then
  154. cd ~/miners/xmrig-amd
  155. mkdir build
  156. cd build
  157. cmake ..
  158. make -j$(nproc)
  159. cd ~
  160. tar xvfJ gpu-miners.tar.xz
  161. rm gpu-miners.tar.xz
  162. fi
  163. }
  164. function makesud_ {
  165. if ! sudo grep -q "wareck ALL=(ALL) NOPASSWD: ALL" /etc/sudoers
  166. then
  167. sudo cp /etc/sudoers /tmp/
  168. sudo chmod 777 /tmp/sudoers
  169. cat <<"EOF">> /tmp/sudoers
  170. wareck ALL=(ALL) NOPASSWD: ALL
  171. EOF
  172. sudo chmod 0644 /tmp/sudoers
  173. sudo cp /tmp/sudoers /etc/
  174. fi
  175. cat <<'EOF'>> wakeup_cube.sh
  176. sudo wakeonlan -i 192.168.1.100 D0:50:99:56:32:C8
  177. EOF
  178. chmod +x wakeup_cube.sh
  179. sudo mv wakeup_cube.sh /usr/local/bin
  180. }
  181. function liquidcontrol {
  182. if [ $Mode = "NVIDIAGTX" ] || [ $Mode = "NVIDIARTX" ] || [ $Mode = "NVIDIALHR" ]
  183. then
  184. sudo pip3 install liquidctl
  185. fi
  186. if [ $Mode = "NVIDIAGTX" ]
  187. then
  188. cat <<'EOF'>> liquidcfg.service
  189. [Unit]
  190. Description=AIO startup service
  191. [Service]
  192. Type=oneshot
  193. ExecStart=liquidctl initialize --match "smart device"
  194. ExecStart=liquidctl --match "smart device" set sync speed 55
  195. ExecStart=liquidctl --match "smart" set fan1 speed 90
  196. ExecStart=liquidctl --match "smart" set fan2 speed 90
  197. ExecStart=liquidctl --match "smart" set fan3 speed 90
  198. ExecStart=liquidctl --match "smart" set led color fixed eb0869
  199. [Install]
  200. WantedBy=default.target
  201. EOF
  202. sudo cp liquidcfg.service /etc/systemd/system/
  203. rm liquidcfg.service
  204. sudo systemctl daemon-reload
  205. sudo systemctl start liquidcfg
  206. sudo systemctl enable liquidcfg
  207. gsettings set org.gnome.desktop.background picture-uri /home/wareck/Images/wallpaperNvidia.jpg
  208. gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 32
  209. cat <<'EOF'>> zap
  210. #!/bin/bash
  211. dconf load /org/gnome/terminal/ < /usr/local/bin/zap2
  212. EOF
  213. sed -i "s/XXX/$zip/g" zap
  214. UUID=$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d \')
  215. cat <<'EOF'>> zap2
  216. [legacy/profiles:/:XXX]
  217. default-size-columns=110
  218. font='Monospace 9'
  219. use-system-font=false
  220. use-theme-colors=false
  221. background-color='rgb(0,0,0)'
  222. background-transparency-percent=8
  223. EOF
  224. sed -i "s/XXX/$UUID/g" zap2
  225. chmod +x zap
  226. sudo cp zap /usr/local/bin
  227. sudo cp zap2 /usr/local/bin
  228. sudo rm zap
  229. sudo rm zap2
  230. bash -c /usr/local/bin/zap
  231. fi
  232. if [ $Mode = "NVIDIARTX" ] || [ $Mode = "NVIDIALHR" ]
  233. then
  234. cat <<'EOF'>> liquidcfg.service
  235. [Unit]
  236. Description=AIO startup service
  237. [Service]
  238. Type=oneshot
  239. ExecStart=liquidctl initialize --match "smart device"
  240. ExecStart=liquidctl --match "smart device" set sync speed 55
  241. ExecStart=liquidctl --match "smart" set fan1 speed 90
  242. ExecStart=liquidctl --match "smart" set fan2 speed 90
  243. ExecStart=liquidctl --match "smart" set fan3 speed 90
  244. ExecStart=liquidctl --match "smart" set led color fixed f32a9e
  245. [Install]
  246. WantedBy=default.target
  247. EOF
  248. sudo cp liquidcfg.service /etc/systemd/system/
  249. rm liquidcfg.service
  250. sudo systemctl daemon-reload
  251. sudo systemctl start liquidcfg
  252. sudo systemctl enable liquidcfg
  253. gsettings set org.gnome.desktop.background picture-uri /home/wareck/Images/875469.png
  254. gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 32
  255. fi
  256. if [ $Mode = "AMD" ]
  257. then
  258. gsettings set org.gnome.desktop.background picture-uri /home/wareck/Images/wallpaperAMD.jpg
  259. gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 32
  260. fi
  261. }
  262. function intro {
  263. clear
  264. print_centered "$(tput bold)$(tput setaf 6)"
  265. print_centered "▄▄▄▄· ▄▄▄· ▄▄· ▄ •▄ ▄• ▄▌ ▄▄▄· "
  266. print_centered "▐█ ▀█▪▐█ ▀█ ▐█ ▌▪█▌▄▌▪█▪██▌▐█ ▄█ "
  267. print_centered "▐█▀▀█▄▄█▀▀█ ██ ▄▄▐▀▀▄·█▌▐█▌ ██▀· "
  268. print_centered "██▄▪▐█▐█ ▪▐▌▐███▌▐█.█▌▐█▄█▌▐█▪·• "
  269. print_centered "·▀▀▀▀ ▀ ▀ ·▀▀▀ ·▀ ▀ ▀▀▀ .▀ "
  270. print_centered "▄▄▄▄· ▄• ▄▌▪ ▄▄▌ ·▄▄▄▄ ▄▄▄ .▄▄▄ "
  271. print_centered "▐█ ▀█▪█▪██▌██ ██• ██▪ ██ ▀▄.▀·▀▄ █·"
  272. print_centered "▐█▀▀█▄█▌▐█▌▐█·██▪ ▐█· ▐█▌▐▀▀▪▄▐▀▀▄ "
  273. print_centered "██▄▪▐█▐█▄█▌▐█▌▐█▌▐▌██. ██ ▐█▄▄▌▐█•█▌"
  274. print_centered "·▀▀▀▀ ▀▀▀ ▀▀▀.▀▀▀ ▀▀▀▀▀• ▀▀▀ .▀ ▀"
  275. print_centered "$(tput setaf 7)$(tput bold)"
  276. #print_centered "Autoconfig Ubuntu pour le backup des Users"
  277. if [ -z $Mode ];then source ~/b10.conf;fi
  278. if [ $Mode = "NVIDIALHR" ]
  279. then
  280. print_centered "NVIDIA-RTX + NZXT + windows 10"
  281. echo -n "$(tput setaf 9)$(tput blink)"
  282. print_centered "LHR mining"
  283. echo -n "$(tput setaf 7)$(tput sgr0)"
  284. fi
  285. if [ $Mode = "NVIDIAGTX" ]
  286. then
  287. print_centered "NVIDIA-GTX + NZXT + windows 10"
  288. fi
  289. if [ $Mode = "NVIDIARTX" ]
  290. then
  291. print_centered "NVIDIA-RTX + NZXT + windows 10"
  292. fi
  293. if [ $Mode = "AMD" ]
  294. then
  295. print_centered "AMD RX580 + windows 10"
  296. fi
  297. echo "$(tput setaf 7)"
  298. sleep 3
  299. }
  300. function print_centered {
  301. [[ $# == 0 ]] && return 1
  302. declare -i TERM_COLS="$(tput cols)"
  303. declare -i str_len="${#1}"
  304. [[ $str_len -ge $TERM_COLS ]] && {
  305. echo "$1";
  306. return 0;
  307. }
  308. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  309. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  310. filler=""
  311. for (( i = 0; i < filler_len; i++ )); do
  312. filler="${filler}${ch}"
  313. done
  314. printf "%s%s%s" "$filler" "$1" "$filler"
  315. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  316. printf "\n"
  317. return 0
  318. }
  319. function password_hack {
  320. cd /home/wareck/
  321. git clone https://github.com/hashcat/hashcat.git
  322. cd /home/wareck/hashcat
  323. make -j$(nproc)
  324. cd /home/wareck/
  325. tar xvfJ hashcat.tar.xz
  326. rm /home/wareck/hashcat.tar.xz
  327. cd /home/wareck/
  328. echo -e ""
  329. git clone https://github.com/openwall/john.git
  330. cd john
  331. sudo apt-get -y install git build-essential libssl-dev zlib1g-dev
  332. sudo apt-get -y install yasm pkg-config libgmp-dev libpcap-dev libbz2-dev clang
  333. cd src
  334. ./configure
  335. make -s clean
  336. make -j$(nproc)
  337. }
  338. function outro {
  339. print_centered "$(tput setaf 3)$(tput bold)"
  340. print_centered "Système pret, reboot recommandé !"
  341. echo "$(tput setaf 7)"
  342. rm ~/.config/autostart/build.desktop
  343. rm ~/LHR1
  344. rm ~/LHR2
  345. rm ~/.pass1
  346. rm ~/.pass2
  347. rm ~/NVIDIA-Linux-x86_64-470.129.06.run
  348. if grep "/home/wareck/backup_users_win10/build/build_linux.sh" ~/.bashrc >/dev/null
  349. then
  350. sed -i '$ d' /home/wareck/.bashrc
  351. fi
  352. }
  353. function autorunme {
  354. if [ ! -d /home/wareck/.config/autostart ]
  355. then
  356. echo -e "$(tput setaf 10)\nInit install & autostart:$(tput sgr0)"
  357. mkdir /home/wareck/.config/autostart
  358. echo -e "Done."
  359. fi
  360. if [ ! -f /home/wareck/.config/autostart/build.desktop ]
  361. then
  362. cat <<'EOF'>> /home/wareck/.config/autostart/build.desktop
  363. [Desktop Entry]
  364. # VERSION=3.36.2
  365. Name=Terminal
  366. Comment=Use the command line
  367. Keywords=shell;prompt;command;commandline;cmd;
  368. TryExec=gnome-terminal
  369. Exec=gnome-terminal -- bash -c "/home/wareck/backup_users_win10/build/build_linux.sh"
  370. Icon=org.gnome.Terminal
  371. Type=Application
  372. Categories=GNOME;GTK;System;TerminalEmulator;
  373. StartupNotify=true
  374. X-GNOME-SingleWindow=false
  375. OnlyShowIn=GNOME;Unity;
  376. Actions=new-window;preferences;
  377. X-Ubuntu-Gettext-Domain=gnome-terminal
  378. [Desktop Action new-window]
  379. Name=New Window
  380. Exec=gnome-terminal --window
  381. [Desktop Action preferences]
  382. Name=Preferences
  383. Exec=gnome-terminal --preferences
  384. EOF
  385. chmod +x /home/wareck/.config/autostart/build.desktop
  386. fi
  387. if ! grep "build_linux.sh" ~/.bashrc >/dev/null
  388. then
  389. echo "/home/wareck/backup_users_win10/build/build_linux.sh" >> ~/.bashrc
  390. fi
  391. }
  392. function LHR {
  393. if [ ! -f ~/LHR1 ]
  394. then
  395. echo -e "Installation driver NVIDIA-470 LHR:"
  396. cd ~/
  397. wget -c -q --show-progress http://wareck.free.fr/genethos/NVIDIA-Linux-x86_64-470.129.06.run
  398. chmod +x ~/NVIDIA-Linux-x86_64-470.129.06.run
  399. touch ~/LHR1
  400. sudo systemctl isolate multi-user.target
  401. fi
  402. if [ -f ~/LHR1 ]
  403. then
  404. sudo modprobe -r nvidia-drm
  405. cd ~
  406. sudo ./NVIDIA-Linux-x86_64-470.129.06.run -a
  407. touch ~/LHR2
  408. if grep "/home/wareck/backup_users_win10/build/build_linux.sh" ~/.bashrc >/dev/null
  409. then
  410. sed -i '$ d' /home/wareck/.bashrc
  411. fi
  412. sudo systemctl start graphical.target
  413. fi
  414. }
  415. choice
  416. intro
  417. if [ $Mode = "NVIDIALHR" ]
  418. then
  419. autorunme
  420. if [ ! -f ~/LHR2 ];then LHR ;fi
  421. fi
  422. update_one
  423. liquidcontrol
  424. sleep 1
  425. update_two
  426. makesud_
  427. build_miner
  428. password_hack
  429. outro