diff --git a/bfds/root/photoprism-auto-index.sh b/bfds/root/photoprism-auto-index.sh new file mode 100644 index 0000000..e548e47 --- /dev/null +++ b/bfds/root/photoprism-auto-index.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# This script runs the index process of PhotoPrism. +# it must be called from a cronjob or similar to ensure it runs periodically. + +# Flag-Datei zur Vermeidung paralleler Ausführungen +FLAG_FILE="/root/photoprism-auto-index.flag" + +# Cleanup-Funktion die IMMER ausgeführt wird (auch bei Fehlern/Abbruch) +cleanup() { + rm -f "$FLAG_FILE" +} + +# trap registriert die cleanup-Funktion für verschiedene Exit-Szenarien: +# EXIT = normales Script-Ende +# INT = CTRL+C (Signal 2) +# TERM = kill-Befehl (Signal 15) +# ERR = wenn ein Befehl fehlschlägt (bei set -e) +trap cleanup EXIT INT TERM ERR + +# Prüfe ob ein anderer Prozess bereits läuft +if [ -f "$FLAG_FILE" ]; then + trap - EXIT INT TERM ERR + exit 1 +fi + +echo "Started: $(date '+%Y-%m-%d %H:%M:%S') | PID: $$" > "$FLAG_FILE" + +# Führe Index-Prozess aus +docker exec ix-photoprism-photoprism-1 photoprism index + +# Flag-Datei wird automatisch durch trap cleanup gelöscht \ No newline at end of file