46664ab3b6
- log() Funktion in darktable_common.sh ausgelagert (war doppelt vorhanden) - ssh_server() Hilfsfunktion für wiederholte SSH-Aufrufe mit konsistenten Optionen - ssh_server() nutzen statt inline SSH-Befehle in darktable_sync.sh und darktable_wrapper.sh - Reduzierung von SSH-Optionswiederbholungen (ConnectTimeout, BatchMode, Port) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
65 lines
1.6 KiB
Bash
Executable File
65 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
set -euo pipefail
|
||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
# shellcheck source=darktable_common.sh
|
||
source "$SCRIPT_DIR/darktable_common.sh"
|
||
|
||
check_dependency darktable
|
||
check_dependency ssh openssh-client
|
||
check_dependency notify-send libnotify-bin
|
||
|
||
load_config
|
||
validate_config
|
||
|
||
export DISPLAY="${DISPLAY:-:0}"
|
||
|
||
if pgrep -x darktable &>/dev/null; then
|
||
notify-send "Darktable" \
|
||
"Darktable laeuft bereits. Bitte zuerst schliessen." -u critical
|
||
exit 1
|
||
fi
|
||
|
||
ACTIVE_MARKER_SET=false
|
||
|
||
cleanup() {
|
||
if [ "$ACTIVE_MARKER_SET" = true ]; then
|
||
ssh_server "rm -f '$SERVER_DB_DIR/darktable.active'" 2>/dev/null || true
|
||
fi
|
||
}
|
||
trap cleanup EXIT INT TERM
|
||
|
||
if ! server_reachable; then
|
||
if ! ask_user "Darktable Sync" \
|
||
"Server nicht erreichbar.\nDarktable ohne Synchronisation starten?"; then
|
||
log "Abbruch durch Benutzer – Server nicht erreichbar."
|
||
exit 0
|
||
fi
|
||
log "Starte Darktable ohne Sync..."
|
||
else
|
||
log "Pre-Sync..."
|
||
"$SYNC_BIN"
|
||
|
||
MARKER="$(hostname) seit $(date '+%Y-%m-%d %H:%M:%S')"
|
||
ssh_server "echo '$MARKER' > '$SERVER_DB_DIR/darktable.active'" || true
|
||
ACTIVE_MARKER_SET=true
|
||
fi
|
||
|
||
log "Starte Darktable..."
|
||
"$DARKTABLE_BIN" "$@" || true
|
||
log "Darktable beendet."
|
||
|
||
if [ "$ACTIVE_MARKER_SET" = true ]; then
|
||
ssh_server "rm -f '$SERVER_DB_DIR/darktable.active'" 2>/dev/null || true
|
||
ACTIVE_MARKER_SET=false
|
||
fi
|
||
|
||
if server_reachable; then
|
||
log "Post-Sync..."
|
||
"$SYNC_BIN"
|
||
else
|
||
touch "$CONFIG_DIR/sync_pending"
|
||
notify-send "Darktable Sync" \
|
||
"Server nicht erreichbar – Sync ausstehend." -t 5000
|
||
fi
|