nvidia_rtx.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/bash
  2. function print_centered {
  3. [[ $# == 0 ]] && return 1
  4. declare -i TERM_COLS="$(tput cols)"
  5. declare -i str_len="${#1}"
  6. [[ $str_len -ge $TERM_COLS ]] && {
  7. echo "$1";
  8. return 0;
  9. }
  10. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  11. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  12. filler=""
  13. for (( i = 0; i < filler_len; i++ )); do
  14. filler="${filler}${ch}"
  15. done
  16. printf "%s%s%s" "$filler" "$1" "$filler"
  17. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  18. printf "\n"
  19. return 0
  20. }
  21. function intro {
  22. print_centered "$(tput setaf 5)"
  23. print_centered "Chroot"
  24. echo -n "$(tput setaf 7)"
  25. }
  26. function nvidia_driver_ {
  27. if ! [ -f /home/wareck/.pass1 ]
  28. then
  29. cd /home/wareck/
  30. wget -c http://wareck.free.fr/genethos/NVIDIA-Linux-x86_64-470.129.06.run
  31. chmod +x /home/wareck/NVIDIA-Linux-x86_64-470.129.06.run
  32. touch /home/wareck/.pass1
  33. sudo systemctl isolate multi-user.target
  34. fi
  35. if ! [ -f /home/wareck/.pass2 ]
  36. then
  37. modprobe -r nvidia-drm
  38. cd /home/wareck/
  39. sudo ./NVIDIA-Linux-x86_64-470.129.06.run -a
  40. touch /home/wareck/.pass2
  41. fi
  42. if ! [ -f /home/wareck/.pass3 ]
  43. then
  44. systemctl start graphical.target
  45. rm /home/wareck/.pass1
  46. rm /home/wareck/.pass2
  47. rm /home/wareck/NVIDIA-Linux-x86_64-470.129.06.run
  48. rm -r -f /home/wareck/.config/autostart/nvidia_rtx.desktop
  49. systemctl start graphical.target
  50. fi
  51. }
  52. function autorunme {
  53. if [ ! -d /home/wareck/.config/autostart ]
  54. then
  55. echo -e "$(tput setaf 10)\nInit install & autostart:$(tput sgr0)"
  56. mkdir /home/wareck/.config/autostart
  57. echo -e "Done."
  58. fi
  59. if [ ! -f /home/wareck/.config/autostart/nvidia_rtx.desktop ]
  60. then
  61. cat <<'EOF'>> /home/wareck/.config/autostart/nvidia_rtx.desktop
  62. [Desktop Entry]
  63. # VERSION=3.36.2
  64. Name=Terminal
  65. Comment=Use the command line
  66. Keywords=shell;prompt;command;commandline;cmd;
  67. TryExec=gnome-terminal
  68. Exec=gnome-terminal -- bash -c "sudo /home/wareck/backup_users_win10/build/nvidia_rtx.sh; exec bash"
  69. Icon=org.gnome.Terminal
  70. Type=Application
  71. Categories=GNOME;GTK;System;TerminalEmulator;
  72. StartupNotify=true
  73. X-GNOME-SingleWindow=false
  74. OnlyShowIn=GNOME;Unity;
  75. Actions=new-window;preferences;
  76. X-Ubuntu-Gettext-Domain=gnome-terminal
  77. [Desktop Action new-window]
  78. Name=New Window
  79. Exec=gnome-terminal --window
  80. [Desktop Action preferences]
  81. Name=Preferences
  82. Exec=gnome-terminal --preferences
  83. EOF
  84. chmod +x /home/wareck/.config/autostart/nvidia_rtx.desktop
  85. fi
  86. if ! grep "wareck" /etc/sudoers >/dev/null
  87. then
  88. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  89. fi
  90. }
  91. intro
  92. autorunme
  93. nvidia_driver_