nvidia_lhr.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #!/bin/bash
  2. if [ ! -f /home/wareck/.lhr ]
  3. then
  4. if (( $EUID != 0 )); then
  5. echo -e "$(tput setaf 9)This must be run as root. Try 'sudo $0'.$(tput setaf 7)"
  6. exit 1
  7. fi
  8. fi
  9. function print_centered {
  10. [[ $# == 0 ]] && return 1
  11. declare -i TERM_COLS="$(tput cols)"
  12. declare -i str_len="${#1}"
  13. [[ $str_len -ge $TERM_COLS ]] && {
  14. echo "$1";
  15. return 0;
  16. }
  17. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  18. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  19. filler=""
  20. for (( i = 0; i < filler_len; i++ )); do
  21. filler="${filler}${ch}"
  22. done
  23. printf "%s%s%s" "$filler" "$1" "$filler"
  24. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  25. printf "\n"
  26. return 0
  27. }
  28. function intro {
  29. if [ ! -f /home/wareck/.lhr ]
  30. then
  31. print_centered "$(tput bold)$(tput setaf 2)"
  32. print_centered " _______ .__ .___.__ ";
  33. print_centered " \ \___ _|__| __| _/|__|____ ";
  34. print_centered " / | \ \/ / |/ __ | | \__ \ ";
  35. print_centered "/ | \ /| / /_/ | | |/ __ \_";
  36. print_centered "\____|__ /\_/ |__\____ | |__(____ /";
  37. print_centered " \/ \/ \/ ";
  38. else
  39. print_centered "$(tput bold)$(tput setaf 2)"
  40. print_centered "Nvidia LHR kernel installer v1.0"
  41. fi
  42. echo -n "$(tput setaf 9)$(tput blink)"
  43. print_centered "LHR mining"
  44. echo -n "$(tput setaf 7)$(tput sgr0)"
  45. echo -n "$(tput setaf 7)"
  46. if ! [ -f /home/wareck/.rtx ]
  47. then
  48. echo -e ""
  49. print_centered "Vous devez d'abord installer NVIDIA-RTX (build_linux.sh)"
  50. print_centered ""
  51. exit
  52. fi
  53. }
  54. function nvidia_driver_ {
  55. if ! [ -f /home/wareck/.pass1 ]
  56. then
  57. cd /home/wareck/
  58. wget -c http://wareck.free.fr/genethos/NVIDIA-Linux-x86_64-470.129.06.run
  59. chmod +x /home/wareck/NVIDIA-Linux-x86_64-470.129.06.run
  60. touch /home/wareck/.pass1
  61. touch /home/wareck/.lhr
  62. sudo systemctl isolate multi-user.target
  63. fi
  64. if ! [ -f /home/wareck/.pass2 ]
  65. then
  66. sudo modprobe -r nvidia-drm
  67. cd /home/wareck/
  68. sudo ./NVIDIA-Linux-x86_64-470.129.06.run -a --install-compat32-libs --dkms --run-nvidia-xconfig --no-backup -q
  69. touch /home/wareck/.pass2
  70. fi
  71. if ! [ -f /home/wareck/.pass3 ]
  72. then
  73. sudo rm /home/wareck/.pass1
  74. sudo rm /home/wareck/.pass2
  75. sudo rm /home/wareck/.lhr
  76. sudo rm /home/wareck/NVIDIA-Linux-x86_64-470.129.06.run
  77. sudo rm /home/wareck/.config/autostart/build.desktop
  78. if grep "nvidia_lhr.sh" /home/wareck/.bashrc >/dev/null
  79. then
  80. sed -i '$ d' /home/wareck/.bashrc
  81. fi
  82. sudo systemctl start graphical.target
  83. fi
  84. }
  85. function autorunme {
  86. if [ ! -f /home/wareck/.lhr ]
  87. then
  88. if ! grep "wareck" /etc/sudoers >/dev/null
  89. then
  90. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  91. fi
  92. if ! grep "nvidia_lhr.sh" /home/wareck/.bashrc >/dev/null
  93. then
  94. echo "/home/wareck/backup_users_win10/build/nvidia_lhr.sh" >> /home/wareck/.bashrc
  95. fi
  96. if [ ! -d /home/wareck/.config/autostart ]
  97. then
  98. echo -e "$(tput setaf 10)\nInit install & autostart:$(tput sgr0)"
  99. mkdir /home/wareck/.config/autostart
  100. echo -e "Done."
  101. fi
  102. if [ ! -f /home/wareck/.config/autostart/build.desktop ]
  103. then
  104. cat <<'EOF'>> /home/wareck/.config/autostart/build.desktop
  105. [Desktop Entry]
  106. # VERSION=3.36.2
  107. Name=Terminal
  108. Comment=Use the command line
  109. Keywords=shell;prompt;command;commandline;cmd;
  110. TryExec=gnome-terminal
  111. Exec=gnome-terminal -- bash -c "/home/wareck/backup_users_win10/build/nvidia_lhr.sh"
  112. Icon=org.gnome.Terminal
  113. Type=Application
  114. Categories=GNOME;GTK;System;TerminalEmulator;
  115. StartupNotify=true
  116. X-GNOME-SingleWindow=false
  117. OnlyShowIn=GNOME;Unity;
  118. Actions=new-window;preferences;
  119. X-Ubuntu-Gettext-Domain=gnome-terminal
  120. [Desktop Action new-window]
  121. Name=New Window
  122. Exec=gnome-terminal --window
  123. [Desktop Action preferences]
  124. Name=Preferences
  125. Exec=gnome-terminal --preferences
  126. EOF
  127. chmod +x /home/wareck/.config/autostart/build.desktop
  128. fi
  129. fi
  130. }
  131. intro
  132. autorunme
  133. nvidia_driver_