Clean up file if no timer is present

This commit is contained in:
David Heinemeier Hansson
2026-03-15 18:48:39 +01:00
parent 3154290769
commit 506348ef4b
+5
View File
@@ -7,6 +7,11 @@
NOPASSWD_FILE="/etc/sudoers.d/99-omarchy-nopasswd-${USER}"
TIMER_NAME="omarchy-nopasswd-expire-${USER}"
# Safety: if the file exists but the timer doesn't (e.g. after reboot), clean up
if sudo test -f "$NOPASSWD_FILE" && ! systemctl is-active "${TIMER_NAME}.timer" &>/dev/null; then
sudo rm "$NOPASSWD_FILE"
fi
# Check for the file directly — sudo -n can stay cached or be granted by other rules
if sudo test -f "$NOPASSWD_FILE"; then
sudo rm "$NOPASSWD_FILE"