diff --git a/Rsync/rsync.sh b/Rsync/rsync.sh index b763cd4..fd857f1 100644 --- a/Rsync/rsync.sh +++ b/Rsync/rsync.sh @@ -87,8 +87,13 @@ done [[ "$REMOTE_OK" != true ]] && error "Remote unreachable" && exit 1 +# ----------------------------- EXECUTION BARRIER ----------------------------- + wait_for_rsync stop_containers +sync +sleep 2 + get_rsync_opts for ex in "${EXCLUDE_DIRS[@]}"; do diff --git a/common.sh b/common.sh index 0ddb6c1..7f1c219 100644 --- a/common.sh +++ b/common.sh @@ -1,8 +1,10 @@ #!/bin/bash # ----------------------------------------------------------------------------------------------- -# ----------------- UNRAID OPS COMMON LIBRARY (CORE FRAMEWORK v1 FIXED) ------------------------- +# ----------------- UNRAID OPS COMMON LIBRARY (FINAL STABLE FRAMEWORK v1) ----------------------- # ----------------------------------------------------------------------------------------------- +# ----------------------------- ICONS ----------------------------- + ICON_INFO="ℹ️" ICON_WARN="⚠️" ICON_ERROR="❌" @@ -13,7 +15,7 @@ ICON_RETRY="🔁" ICON_SYNC="🔄" ICON_GEAR="⚙️" -# ----------------------------- Output ----------------------------- +# ----------------------------- OUTPUT ----------------------------- info() { echo "$ICON_INFO [INFO] $*"; } warn() { echo "$ICON_WARN [WARN] $*"; } @@ -24,7 +26,7 @@ log() { [[ "${ENABLE_LOGGING:-false}" == true ]] && echo "[LOG] $*" } -# ----------------------------- Args ----------------------------- +# ----------------------------- ARG PARSER ----------------------------- parse_args() { ENABLE_LOGGING=${ENABLE_LOGGING:-false} @@ -70,13 +72,13 @@ parse_args() { PARSED_ARGS=("${CLEAN_ARGS[@]}") } -# ----------------------------- Validation ----------------------------- +# ----------------------------- VALIDATION ----------------------------- require_var() { [[ -z "${!1:-}" ]] && error "Missing required: $1" && exit 1 } -# ----------------------------- Host Detection ----------------------------- +# ----------------------------- HOST DETECTION ----------------------------- detect_hosts() { LOCAL_HOSTNAME="$(hostname)" @@ -103,7 +105,7 @@ detect_hosts() { info "Host: $LOCAL_SERVER_NAME → $REMOTE_SERVER_NAME" } -# ----------------------------- Remote ----------------------------- +# ----------------------------- REMOTE ----------------------------- resolve_remote_ip() { log "Resolving remote IP..." @@ -114,7 +116,7 @@ resolve_remote_ip() { info "Remote IP: $REMOTE_SERVER" } -# ----------------------------- Containers ----------------------------- +# ----------------------------- CONTAINERS ----------------------------- RUNNING_CONTAINERS=() @@ -147,7 +149,7 @@ start_containers() { done } -# ----------------------------- RSYNC LIMITER (FIX ADDED) ----------------------------- +# ----------------------------- RSYNC LIMITER (FIXED FINAL) ----------------------------- wait_for_rsync() { : "${RETRY_COUNT:=5}" @@ -155,7 +157,9 @@ wait_for_rsync() { : "${SLEEP:=2}" for i in $(seq 1 "$RETRY_COUNT"); do - COUNT=$(pgrep -fc "rsync.*root@${REMOTE_SERVER}" || true) + + # stable + cross-system safe + COUNT=$(pgrep -af rsync | wc -l) if [[ "$COUNT" -ge "$MAX_RSYNC_PROCS" ]]; then warn "Waiting rsync slot ($COUNT/$MAX_RSYNC_PROCS)"