Advertisement
slyfox1186

enable-headless-or-vga-mode-ubuntu.sh

Nov 1st, 2022 (edited)
1,363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.31 KB | None | 0 0
  1. #!/bin/sudo bash
  2.  
  3. clear
  4.  
  5. echo -e "This script will allow the user to quickly switch Ubuntu Desktop"
  6. echo -e "into it's VGA or Headless Client mode as dictated by the startup"
  7. echo -e "commands located in /etc/default/grub.\\n"
  8. echo -e "This has been only tested on my pc using Ubuntu Jammy 22.04.1"
  9. echo -e "Please run this script at your own risk as I assume none.\\n"
  10. read -p 'Press Enter to continue.'
  11.  
  12. clear
  13.  
  14. FILE='/etc/default/grub'
  15.  
  16. echo '[1] Headless Mode'
  17. echo '[2] VGA Mode'
  18. echo -e "[3] Exit\\n"
  19. read -p 'Enter a number: ' i
  20.  
  21. clear
  22.  
  23. if [[ "$i" -eq "1"  ]]; then sudo sed -i 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="3"/g' $FILE
  24. elif [[ "$i" -eq "2"  ]]; then sudo sed -i 's/GRUB_CMDLINE_LINUX="3"/GRUB_CMDLINE_LINUX=""/g' $FILE
  25. elif [[ "$i" -eq "3"  ]]; then clear; ls -hF1AX --group-directories-first --color; exit
  26. else
  27.     echo '[i] Input Error: Please from choose one of the following numbers:'
  28.     echo -e "    [1] , [2] , [3]\\n"
  29.     read -p 'Press Enter to start over or Ctrl+C to exit. '
  30.     clear; sudo bash "$0"
  31.     exit 1
  32. fi
  33.  
  34. clear; unset i
  35.  
  36. echo -e "Do you want to update grub?\\n"
  37. echo '[1] Yes'
  38. echo -e "[2] No\\n"
  39. read -p 'Enter a number: ' i
  40.  
  41. clear
  42.  
  43. if [[ "$i" -eq "1"  ]]; then
  44.     sudo update-grub
  45.     echo
  46. elif [[ "$i" -eq "2"  ]]; then echo ''; fi
  47.  
  48. unset i
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement