mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-10 19:27:02 +01:00
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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PcdngP688mW6rJye3LRkSN
This commit is contained in:
parent
ccb0018a2c
commit
ada7e69c60
16
install.sh
16
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 ==="
|
||||
|
||||
Loading…
Reference in New Issue
Block a user