Files
darktable-sync/uninstall.sh
martin 92a5d50082 Sicherheitshaertung: Injection-Schutz, atomares Locking, Pfad-Validierung
- load_config blockiert Shell-Operatoren (;|&`) in .env-Werten
- validate_path prueft Sonderzeichen und Path-Traversal in Pfad-Variablen
- validate_config prüft DARKTABLE_BIN-basename und ruft validate_path auf
- Lockdir-Trap erst nach erfolgreicher Lock-Akquisition registriert
  (verhindert dass externer Lockdir bei gescheitertem Lock entfernt wird)
- uninstall.sh nutzt rmdir statt rm -rf fuer Lockdir
- security.bats mit 10 Tests fuer alle Sicherheitsanforderungen

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 19:57:39 +02:00

71 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
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}"
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
### Lockdir entfernen (atomares Lock)
LOCKDIR="$CONFIG_DIR/sync.lock"
if [ -d "$LOCKDIR" ]; then
echo "Lockdir entfernen: $LOCKDIR"
rmdir "$LOCKDIR" 2>/dev/null || true
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."