Files
deadman-switch/scripts/cleanup.sh
zenn aeaa1b37c2 feat: rename app to Last Signal
Rename service, UI, storage, and target-path configuration; clarify expiration cleanup behavior.
2026-09-30 11:55:58 +09:00

36 lines
759 B
Bash
Executable File

#!/bin/sh
set -eu
TARGET="${TARGET_PATH:-/home/zenn/Collection}"
case "$TARGET" in
/*) ;;
*)
echo "[last-signal] refused non-absolute target path: $TARGET"
exit 1
;;
esac
if [ -L "$TARGET" ]; then
echo "[last-signal] refused symbolic-link target: $TARGET"
exit 1
fi
if [ ! -d "$TARGET" ]; then
if [ -e "$TARGET" ]; then
echo "[last-signal] refused non-directory target: $TARGET"
exit 1
fi
echo "[last-signal] target directory not found: $TARGET"
exit 0
fi
TARGET_REAL="$(CDPATH= cd "$TARGET" && pwd -P)"
if [ "$TARGET_REAL" = "/" ]; then
echo "[last-signal] refused filesystem root"
exit 1
fi
find "$TARGET_REAL" -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +
echo "[last-signal] deleted contents of: $TARGET_REAL"