From ada7e69c6011914345417a8b68263d2c56c702d4 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sun, 30 Aug 2026 15:38:30 +0200 Subject: [PATCH] Don't let the retired-cleanup abort a working install install.sh runs under `set -euo pipefail` and step 3 called uninstall.sh, which uses `sudo rm`. On a machine without cached or passwordless sudo that call fails, so the install aborted at step 3 -- after the package was installed and the timer enabled. It would report failure for an install that had actually worked, which is precisely the half-finished state the sudo-refusal guard at the top of the script exists to prevent. The vmbox harness could not have caught this: the guest's `arch` user has passwordless sudo, which is why the run went green. The cleanup is opportunistic -- a machine with no /usr/local/bin/shutdown needs nothing done -- so it is now non-fatal, gated on `sudo -n` so it cannot hang on a password prompt in a non-TTY context either. When it is skipped the script says why it matters and gives the exact command, rather than leaving the shutdown wrapper in place silently. Verified: uninstall.sh --retired-only and install.sh are both idempotent and exit 0 on a host where the retired pieces are already gone. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01PcdngP688mW6rJye3LRkSN --- install.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 5fa0fde..66cd598 100755 --- a/install.sh +++ b/install.sh @@ -60,7 +60,21 @@ systemctl --user enable --now wake-alarm-trigger.timer echo " Trigger timer enabled and started (ticks once a minute)." echo "[3/3] Removing retired waking machinery from earlier installs..." -bash "$SCRIPT_DIR/uninstall.sh" --retired-only +# Opportunistic, and deliberately NOT fatal. This script runs under `set -e` +# and the cleanup needs root, so on a machine without cached/passwordless sudo +# a hard call would abort the install *after* the package and timer are +# already in place -- reporting failure for an install that actually worked. +# `sudo -n` rather than plain sudo so it cannot hang on a password prompt in a +# non-TTY context either. +if sudo -n true 2>/dev/null; then + bash "$SCRIPT_DIR/uninstall.sh" --retired-only || + echo " Cleanup incomplete — run: bash uninstall.sh --retired-only" +else + echo " Needs root and sudo would prompt; skipping." + echo " Run it yourself: bash uninstall.sh --retired-only" + echo " This matters: /usr/local/bin/shutdown otherwise keeps turning" + echo " 'shutdown now' into a hibernate." +fi echo echo "=== Installation complete ==="