add photo-prism auto index script

This commit is contained in:
trnq1ll0 committed 2025-10-02 06:10:12 +02:00
1 parent 4e0dae29c3
commit 69814c3396
1 file changed
+31
+31
View File
@@ -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