diff --git a/home/dot_local/bin/executable_provision.tmpl b/home/dot_local/bin/executable_provision.tmpl index 6132351e..6ff259f3 100644 --- a/home/dot_local/bin/executable_provision.tmpl +++ b/home/dot_local/bin/executable_provision.tmpl @@ -10,11 +10,18 @@ {{ includeTemplate "universal/logg" }} -### Prompt for sudo password and (optionally) enable passwordless sudo +### Prompt for sudo password +sudo -n true || SUDO_EXIT_CODE=$? logg info 'Your user will temporarily be granted passwordless sudo for the duration of the script' -logg info 'Press `CTRL+C` to bypass this prompt to either enter your password when needed or perform a non-privileged installation' -logg info 'Note: Non-privileged installations are not yet supported' -echo "$(whoami) ALL=(ALL:ALL) NOPASSWD: ALL # TEMPORARY FOR INSTALL DOCTOR" | sudo tee -a /etc/sudoers +if [ -n "$SUDO_EXIT_CODE" ]; then + logg info 'Press `CTRL+C` to bypass this prompt to either enter your password when needed or perform a non-privileged installation' + logg info 'Note: Non-privileged installations are not yet supported' +fi + +### Enable passwordless sudo +if ! sudo cat /etc/sudoers | grep '# TEMPORARY FOR INSTALL DOCTOR' > /dev/null; then + echo "$(whoami) ALL=(ALL:ALL) NOPASSWD: ALL # TEMPORARY FOR INSTALL DOCTOR" | sudo tee -a /etc/sudoers +fi ### Ensure ~/.local/share/megabyte-labs is a directory if [ ! -d "${XDG_DATA_DIR:-$HOME/.local/share}/megabyte-labs" ]; then diff --git a/local/provision.sh b/local/provision.sh index ffab0db8..694f3f87 100644 --- a/local/provision.sh +++ b/local/provision.sh @@ -180,11 +180,18 @@ logg() { fi } -### Prompt for sudo password and (optionally) enable passwordless sudo +### Prompt for sudo password +sudo -n true || SUDO_EXIT_CODE=$? logg info 'Your user will temporarily be granted passwordless sudo for the duration of the script' -logg info 'Press `CTRL+C` to bypass this prompt to either enter your password when needed or perform a non-privileged installation' -logg info 'Note: Non-privileged installations are not yet supported' -echo "$(whoami) ALL=(ALL:ALL) NOPASSWD: ALL # TEMPORARY FOR INSTALL DOCTOR" | sudo tee -a /etc/sudoers +if [ -n "$SUDO_EXIT_CODE" ]; then + logg info 'Press `CTRL+C` to bypass this prompt to either enter your password when needed or perform a non-privileged installation' + logg info 'Note: Non-privileged installations are not yet supported' +fi + +### Enable passwordless sudo +if ! sudo cat /etc/sudoers | grep '# TEMPORARY FOR INSTALL DOCTOR' > /dev/null; then + echo "$(whoami) ALL=(ALL:ALL) NOPASSWD: ALL # TEMPORARY FOR INSTALL DOCTOR" | sudo tee -a /etc/sudoers +fi ### Qubes dom0 if command -v qubesctl > /dev/null; then