From f8b698e62a7d38acc17ab2ffe172ad44c52d94f3 Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Wed, 25 Jan 2023 12:43:23 +0000 Subject: [PATCH] Update 2 files - /local/provision.sh - /home/dot_local/bin/executable_provision.tmpl --- home/dot_local/bin/executable_provision.tmpl | 15 +++++++++++---- local/provision.sh | 15 +++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) 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