Robuste Darktable-Synchronisation: sequenzieller Ablauf, Versions- und Concurrent-Schutz
- Race Condition behoben: Pre-Sync wird vollstaendig abgewartet bevor Darktable startet - Post-Sync nach Schliessen von Darktable eingefuehrt (bisher fehlend) - .env aus festem Pfad ~/.config/darktable-sync/.env geladen (nicht mehr relativ) - Server-Erreichbarkeit per SSH statt ping (Firewall-sicher) - Darktable-Versionscheck (Major.Minor) vor Download mit Abbruch bei Konflikt - DB-Backup vor jedem Download (library.db.bak, data.db.bak) - sync_pending-Marker bei Offline/Fehler, Hinweis beim naechsten Start - darktable.active-Marker auf Server fuer Concurrent-Erkennung - Lock-Dateien vom Sync ausgeschlossen - systemd-Timer entfernt, Service bleibt als manueller Trigger - Gemeinsame Hilfsfunktionen in darktable_common.sh extrahiert - 20 BATS-Tests mit vollstaendigem Stub-System ohne GUI-Dialoge Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+60
-17
@@ -1,27 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Load possible custom paths from install-time .env if exists
|
||||
if [[ -f ".env" ]]; then
|
||||
export $(grep -v '^#' .env | xargs)
|
||||
fi
|
||||
set -e
|
||||
|
||||
CONFIG_DIR="${CONFIG_DIR:-$HOME/.config/darktable-sync}"
|
||||
BIN_DIR="${BIN_DIR:-$HOME/.local/bin}"
|
||||
APPLICATIONS_DIR="${APPLICATIONS_DIR:-$HOME/.local/share/applications}"
|
||||
SYSTEMD_USER_DIR="${SYSTEMD_USER_DIR:-$HOME/.config/systemd/user}"
|
||||
|
||||
# Stop and disable systemd service
|
||||
echo "🛑 Removing systemd services..."
|
||||
systemctl --user disable --now darktable-sync.timer >/dev/null 2>&1 || true
|
||||
if [[ -f "$CONFIG_DIR/.env" ]]; then
|
||||
# shellcheck source=/dev/null
|
||||
. "$CONFIG_DIR/.env"
|
||||
fi
|
||||
|
||||
### Systemd deaktivieren
|
||||
|
||||
echo "Systemd-Services entfernen..."
|
||||
systemctl --user disable --now darktable-sync.timer 2>/dev/null || true
|
||||
systemctl --user disable --now darktable_sync.timer 2>/dev/null || true
|
||||
systemctl --user daemon-reload
|
||||
|
||||
# Remove files
|
||||
echo "🧹 Cleaning up installed files..."
|
||||
rm -fv \
|
||||
"$BIN_DIR/darktable_sync.sh" \
|
||||
"$BIN_DIR/darktable_wrapper.sh" \
|
||||
"$APPLICATIONS_DIR/darktable-with-sync.desktop" \
|
||||
"$APPLICATIONS_DIR/darktable-sync-only.desktop" \
|
||||
"$SYSTEMD_USER_DIR/darktable-sync.service" \
|
||||
"$SYSTEMD_USER_DIR/darktable-sync.timer"
|
||||
### Lockfile entfernen
|
||||
|
||||
echo "✅ Uninstall complete. Config files in ~/.config/darktable remain untouched."
|
||||
LOCKFILE="/tmp/darktable_sync.sh.lock"
|
||||
if [ -f "$LOCKFILE" ]; then
|
||||
echo "Lockfile entfernen: $LOCKFILE"
|
||||
rm -f "$LOCKFILE"
|
||||
fi
|
||||
|
||||
### Aktiven Marker auf Server entfernen (best-effort)
|
||||
|
||||
if [[ -n "${SERVER_IP:-}" ]] && [[ -n "${SERVER_DB_DIR:-}" ]]; then
|
||||
if ssh -o ConnectTimeout=5 -o BatchMode=yes \
|
||||
-p "${SERVER_SSH_PORT:-22}" "${SERVER_USER:-$USER}@$SERVER_IP" true 2>/dev/null; then
|
||||
echo "Active-Marker auf Server entfernen..."
|
||||
ssh -o ConnectTimeout=5 -o BatchMode=yes \
|
||||
-p "${SERVER_SSH_PORT:-22}" "${SERVER_USER:-$USER}@$SERVER_IP" \
|
||||
"rm -f '$SERVER_DB_DIR/darktable.active'" 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
|
||||
### Installierte Dateien entfernen
|
||||
|
||||
echo "Installierte Dateien entfernen..."
|
||||
rm -fv \
|
||||
"$BIN_DIR/darktable_common.sh" \
|
||||
"$BIN_DIR/darktable_sync.sh" \
|
||||
"$BIN_DIR/darktable_wrapper.sh" \
|
||||
"$APPLICATIONS_DIR/darktable-with-sync.desktop" \
|
||||
"$APPLICATIONS_DIR/darktable-sync-only.desktop" \
|
||||
"$SYSTEMD_USER_DIR/darktable-sync.service" \
|
||||
"$SYSTEMD_USER_DIR/darktable-sync.timer" \
|
||||
"$SYSTEMD_USER_DIR/darktable_sync.service" \
|
||||
"$SYSTEMD_USER_DIR/darktable_sync.timer"
|
||||
|
||||
### Config-Verzeichnis aufraumen
|
||||
|
||||
if [ -d "$CONFIG_DIR" ]; then
|
||||
read -r -p "Konfigurationsverzeichnis $CONFIG_DIR loeschen? [j/N] " ans
|
||||
if [[ "$ans" =~ ^[jJyY] ]]; then
|
||||
rm -rfv "$CONFIG_DIR"
|
||||
echo "Konfigurationsverzeichnis entfernt."
|
||||
else
|
||||
echo "Konfigurationsverzeichnis bleibt erhalten: $CONFIG_DIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Deinstallation abgeschlossen."
|
||||
echo "Die Darktable-Datenbank (~/.config/darktable/) bleibt unveraendert."
|
||||
|
||||
Reference in New Issue
Block a user