From 69814c3396df95d62629abc8034180248dabefa8 Mon Sep 17 00:00:00 2001 From: trnq1ll0 Date: Thu, 2 Oct 2025 06:10:12 +0200 Subject: [PATCH] add photo-prism auto index script --- bfds/root/photoprism-auto-index.sh | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 bfds/root/photoprism-auto-index.sh 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