feat: one-time sudo at start with background keep-alive, no more password prompts

This commit is contained in:
2026-05-29 01:13:57 +02:00
parent ad46515b5a
commit 416487260c
2 changed files with 33 additions and 0 deletions

View File

@@ -32,9 +32,39 @@ is_root() {
[[ "$EUID" -eq 0 ]]
}
OMERON_SUDO_PID=""
OMERON_SUDO_PID=""
sudo_init() {
if is_root; then
return 0
fi
tui_info "Sudo access needed — enter your password once"
sudo -v || {
tui_error "Sudo authentication failed"
return 1
}
(
while true; do
sleep 240
sudo -v 2>/dev/null || break
done
) &
OMERON_SUDO_PID=$!
}
sudo_cleanup() {
[[ -n "$OMERON_SUDO_PID" ]] && kill "$OMERON_SUDO_PID" 2>/dev/null || true
}
sudo_run() {
if is_root; then
"$@"
return
fi
if [[ -n "${OMERON_SUDO_PID:-}" ]] && kill -0 "$OMERON_SUDO_PID" 2>/dev/null; then
sudo -n "$@"
else
sudo "$@"
fi