From 65789f532855cb35bc6c4e96159c97744ce6dc4b Mon Sep 17 00:00:00 2001 From: Pipo Date: Sat, 27 Sep 2025 17:32:23 +0200 Subject: [PATCH] correctes comments --- scripts/auto-snapclean-listener.sh | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/scripts/auto-snapclean-listener.sh b/scripts/auto-snapclean-listener.sh index 6f13e4d..36cf068 100644 --- a/scripts/auto-snapclean-listener.sh +++ b/scripts/auto-snapclean-listener.sh @@ -1,11 +1,10 @@ #!/bin/zsh set -e -u -set -o pipefail # zsh: pipefail so wirklich aktiv +set -o pipefail LOGF="/var/log/snapclean.log" log() { print -r -- "$(date '+%F %T') $*" >> "$LOGF"; } -# minimaler PATH für launchd-Umgebung export PATH="/usr/bin:/bin:/usr/sbin:/sbin" is_running() { @@ -22,39 +21,36 @@ wait_until_tm_idle() { while is_running; do sleep 2 (( i++ )) - [[ $i -gt 150 ]] && log "Timeout: TM noch Running, breche Warten ab." && break + [[ $i -gt 150 ]] && log "Timeout: TM still running. Abort" && break done set -e - log "TM jetzt idle (oder Timeout erreicht)." return 0 } delete_all_snapshots() { - log "Snapshots vor Delete (/):" + log "Snapshots before deletion (/):" /usr/bin/tmutil listlocalsnapshots / >>"$LOGF" 2>&1 || log "listlocalsnapshots(/): none/error" - log "Lösche alle lokalen Snapshots auf / …" + log "Delete all local snapshots at / …" set +e /usr/bin/tmutil deletelocalsnapshots / >>"$LOGF" 2>&1 local rc=$? set -e - log "Fertig gelöscht. (rc=${rc})" + log "Deletion successfull. (rc=${rc})" } -# Sicherstellen, dass Logfile existiert (läuft als root – kein sudo nötig) +# Make sure the logfile exists [[ -f "$LOGF" ]] || { : > "$LOGF"; /bin/chmod 644 "$LOGF"; } -# KEINE Pipe → keine Subshell-Probleme while IFS= read -r line; do - # nur die konkrete Zeile matchen, die du gepostet hast if print -r -- "$line" | /usr/bin/grep -q \ "com.apple.TimeMachine:LocalSnapshotManagement] Created Time Machine local snapshot"; then log "Event erkannt: $line" - # Warten bis Time Machine fertig ist + # Wait until Timemachine has finished wait_until_tm_idle - # Ein Hauch warten, bis der Snapshot sicher im Index steht + # Wait a moment until the the snapshot is in index sleep 10 - # Dann alle lokalen Snapshots löschen + # Delete all local snapshots delete_all_snapshots fi done < <(