Code-Vereinfachung: Redundanzen entfernen und Wiederverwendung verbessern
- 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>
This commit is contained in:
@@ -14,10 +14,6 @@ validate_config
|
||||
|
||||
export DISPLAY="${DISPLAY:-:0}"
|
||||
|
||||
log() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
|
||||
}
|
||||
|
||||
if pgrep -x darktable &>/dev/null; then
|
||||
notify-send "Darktable" \
|
||||
"Darktable laeuft bereits. Bitte zuerst schliessen." -u critical
|
||||
@@ -28,9 +24,7 @@ ACTIVE_MARKER_SET=false
|
||||
|
||||
cleanup() {
|
||||
if [ "$ACTIVE_MARKER_SET" = true ]; then
|
||||
ssh -o ConnectTimeout=5 -o BatchMode=yes \
|
||||
-p "$SERVER_SSH_PORT" "$SERVER_USER@$SERVER_IP" \
|
||||
"rm -f '$SERVER_DB_DIR/darktable.active'" 2>/dev/null || true
|
||||
ssh_server "rm -f '$SERVER_DB_DIR/darktable.active'" 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
@@ -47,9 +41,7 @@ else
|
||||
"$SYNC_BIN"
|
||||
|
||||
MARKER="$(hostname) seit $(date '+%Y-%m-%d %H:%M:%S')"
|
||||
ssh -o ConnectTimeout=5 -o BatchMode=yes \
|
||||
-p "$SERVER_SSH_PORT" "$SERVER_USER@$SERVER_IP" \
|
||||
"echo '$MARKER' > '$SERVER_DB_DIR/darktable.active'" || true
|
||||
ssh_server "echo '$MARKER' > '$SERVER_DB_DIR/darktable.active'" || true
|
||||
ACTIVE_MARKER_SET=true
|
||||
fi
|
||||
|
||||
@@ -58,9 +50,7 @@ log "Starte Darktable..."
|
||||
log "Darktable beendet."
|
||||
|
||||
if [ "$ACTIVE_MARKER_SET" = true ]; then
|
||||
ssh -o ConnectTimeout=5 -o BatchMode=yes \
|
||||
-p "$SERVER_SSH_PORT" "$SERVER_USER@$SERVER_IP" \
|
||||
"rm -f '$SERVER_DB_DIR/darktable.active'" 2>/dev/null || true
|
||||
ssh_server "rm -f '$SERVER_DB_DIR/darktable.active'" 2>/dev/null || true
|
||||
ACTIVE_MARKER_SET=false
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user