diff --git a/home/dot_local/bin/executable_provision.tmpl b/home/dot_local/bin/executable_provision.tmpl index a978a13c..1663ee8a 100644 --- a/home/dot_local/bin/executable_provision.tmpl +++ b/home/dot_local/bin/executable_provision.tmpl @@ -18,9 +18,13 @@ if [ -n "$SUDO_EXIT_CODE" ]; then logg info 'Note: Non-privileged installations are not yet supported' fi -### Enable passwordless sudo +# @description Add current user to /etc/sudoers so that headless automation is possible 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 + if [ -n "$SUDO_PASSWORD" ]; then + printf '%s\n' "$SUDO_PASSWORD" | sudo -p "" -S echo "$(whoami) ALL=(ALL:ALL) NOPASSWD: ALL # TEMPORARY FOR INSTALL DOCTOR" | sudo tee -a /etc/sudoers + else + echo "$(whoami) ALL=(ALL:ALL) NOPASSWD: ALL # TEMPORARY FOR INSTALL DOCTOR" | sudo tee -a /etc/sudoers + fi fi ### Ensure ~/.local/share/megabyte-labs is a directory diff --git a/local/provision.sh b/local/provision.sh index 89d938e0..ca16c80d 100644 --- a/local/provision.sh +++ b/local/provision.sh @@ -195,9 +195,13 @@ if [ -n "$SUDO_EXIT_CODE" ]; then logg info 'Note: Non-privileged installations are not yet supported' fi -### Enable passwordless sudo +# @description Add current user to /etc/sudoers so that headless automation is possible 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 + if [ -n "$SUDO_PASSWORD" ]; then + printf '%s\n' "$SUDO_PASSWORD" | sudo -p "" -S echo "$(whoami) ALL=(ALL:ALL) NOPASSWD: ALL # TEMPORARY FOR INSTALL DOCTOR" | sudo tee -a /etc/sudoers + else + echo "$(whoami) ALL=(ALL:ALL) NOPASSWD: ALL # TEMPORARY FOR INSTALL DOCTOR" | sudo tee -a /etc/sudoers + fi fi ### Qubes dom0 diff --git a/scripts/provision.sh b/scripts/provision.sh index bd85ce8b..c86a911f 100644 --- a/scripts/provision.sh +++ b/scripts/provision.sh @@ -163,7 +163,11 @@ fi # @description Add current user to /etc/sudoers so that headless automation is possible 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 + if [ -n "$SUDO_PASSWORD" ]; then + printf '%s\n' "$SUDO_PASSWORD" | sudo -p "" -S echo "$(whoami) ALL=(ALL:ALL) NOPASSWD: ALL # TEMPORARY FOR INSTALL DOCTOR" | sudo tee -a /etc/sudoers + else + echo "$(whoami) ALL=(ALL:ALL) NOPASSWD: ALL # TEMPORARY FOR INSTALL DOCTOR" | sudo tee -a /etc/sudoers + fi fi # @section Qubes dom0 Bootstrap diff --git a/scripts/src/provision.sh.tmpl b/scripts/src/provision.sh.tmpl index e0cfadb6..fb69a5c6 100644 --- a/scripts/src/provision.sh.tmpl +++ b/scripts/src/provision.sh.tmpl @@ -105,7 +105,11 @@ fi # @description Add current user to /etc/sudoers so that headless automation is possible 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 + if [ -n "$SUDO_PASSWORD" ]; then + printf '%s\n' "$SUDO_PASSWORD" | sudo -p "" -S echo "$(whoami) ALL=(ALL:ALL) NOPASSWD: ALL # TEMPORARY FOR INSTALL DOCTOR" | sudo tee -a /etc/sudoers + else + echo "$(whoami) ALL=(ALL:ALL) NOPASSWD: ALL # TEMPORARY FOR INSTALL DOCTOR" | sudo tee -a /etc/sudoers + fi fi # @section Qubes dom0 Bootstrap