Print logs while installing. Add editor support.

The useful edit command `sudo-nopasswd` now supports
custom editor use (BUGFIX).
This commit is contained in:
2026-04-11 21:02:15 +01:00
parent 75f7fa28dc
commit 39ae0a731a
3 changed files with 31 additions and 2 deletions

View File

@@ -1,6 +1,23 @@
#!/bin/bash
set -e
[ "$EUID" -eq 0 ] || { sudo "$0" "$@"; exit $?; }
[ "$EUID" -eq 0 ] || { sudo "$0" "$@" "$EDITOR"; exit $?; }
editor="${!#}"
if [ -z "$editor" ]; then
editor="${EDITOR:-}"
if [ -z "$editor" ]; then
if command -v vim >/dev/null 2>&1; then
editor="vim"
elif command -v nano >/dev/null 2>&1; then
editor="nano"
else
echo "No editor found. Please set the EDITOR environment variable or pass an editor as an argument."
exit 1
fi
set -- "${@:1:$(($#-1))}"
fi
else
EDITOR="$editor"
fi
SHARE_ROOTS=("$HOME/.local/share" "/usr/local/share" "/usr/share")
for SHARE_ROOT in "${SHARE_ROOTS[@]}"; do
if [ -d "$SHARE_ROOT/sudo-nopasswd" ]; then

View File

@@ -18,3 +18,8 @@ INITD_DIR="/etc/init.d"
UPDATE_COMMAND="update-sudo-nopasswd"
WATCH_COMMAND="watch-sudo-nopasswd"
EDIT_COMMAND="sudo-nopasswd"
if [ ! "$SHARE_DIR" ]; then
SHARE_DIR="/usr/share/sudo-nopasswd"
fi