Geloeschte NC-Verbindungen vor Laufzeitabruf entfernen

This commit is contained in:
Terranom674
2026-08-18 16:03:40 +02:00
parent 8fc0ae96d4
commit b562309c6e

View File

@@ -3,6 +3,8 @@ set -Eeuo pipefail
CONFIG_DIR="/etc/bratonien-tools/nc-connector" CONFIG_DIR="/etc/bratonien-tools/nc-connector"
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
PIWIGO_ROOT="${PIWIGO_ROOT:-/var/www/piwigo}"
TOMBSTONE_DIR="${PIWIGO_ROOT%/}/_data/bratonien-tools/nc-connector-status"
shopt -s nullglob shopt -s nullglob
configs=("$CONFIG_DIR"/connection-*.conf) configs=("$CONFIG_DIR"/connection-*.conf)
@@ -13,7 +15,22 @@ fi
result=0 result=0
for config in "${configs[@]}"; do for config in "${configs[@]}"; do
echo "NC Connector: $(basename "$config")" name="$(basename "$config")"
connection_id=""
if [[ "$name" =~ ^connection-([0-9]+)\.conf$ ]]; then
connection_id="${BASH_REMATCH[1]}"
fi
if [[ -n "$connection_id" && -f "$TOMBSTONE_DIR/deleted-$connection_id" ]]; then
echo "NC Connector: Verbindung $connection_id wurde geloescht; Laufzeitdateien werden entfernt."
rm -f -- "$CONFIG_DIR/connection-$connection_id.conf" \
"$CONFIG_DIR/connection-$connection_id.db-password" \
"$CONFIG_DIR/connection-$connection_id.piwigo-password" \
"$CONFIG_DIR/connection-$connection_id.storages.tsv"
continue
fi
echo "NC Connector: $name"
if ! env PIWIGO_CONFIG="$config" bash "$SCRIPT_DIR/sync.sh"; then if ! env PIWIGO_CONFIG="$config" bash "$SCRIPT_DIR/sync.sh"; then
result=1 result=1
fi fi