test
This commit is contained in:
@@ -87,8 +87,13 @@ done
|
|||||||
|
|
||||||
[[ "$REMOTE_OK" != true ]] && error "Remote unreachable" && exit 1
|
[[ "$REMOTE_OK" != true ]] && error "Remote unreachable" && exit 1
|
||||||
|
|
||||||
|
# ----------------------------- EXECUTION BARRIER -----------------------------
|
||||||
|
|
||||||
wait_for_rsync
|
wait_for_rsync
|
||||||
stop_containers
|
stop_containers
|
||||||
|
sync
|
||||||
|
sleep 2
|
||||||
|
|
||||||
get_rsync_opts
|
get_rsync_opts
|
||||||
|
|
||||||
for ex in "${EXCLUDE_DIRS[@]}"; do
|
for ex in "${EXCLUDE_DIRS[@]}"; do
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ----------------- UNRAID OPS COMMON LIBRARY (CORE FRAMEWORK v1 FIXED) -------------------------
|
# ----------------- UNRAID OPS COMMON LIBRARY (FINAL STABLE FRAMEWORK v1) -----------------------
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ----------------------------- ICONS -----------------------------
|
||||||
|
|
||||||
ICON_INFO="ℹ️"
|
ICON_INFO="ℹ️"
|
||||||
ICON_WARN="⚠️"
|
ICON_WARN="⚠️"
|
||||||
ICON_ERROR="❌"
|
ICON_ERROR="❌"
|
||||||
@@ -13,7 +15,7 @@ ICON_RETRY="🔁"
|
|||||||
ICON_SYNC="🔄"
|
ICON_SYNC="🔄"
|
||||||
ICON_GEAR="⚙️"
|
ICON_GEAR="⚙️"
|
||||||
|
|
||||||
# ----------------------------- Output -----------------------------
|
# ----------------------------- OUTPUT -----------------------------
|
||||||
|
|
||||||
info() { echo "$ICON_INFO [INFO] $*"; }
|
info() { echo "$ICON_INFO [INFO] $*"; }
|
||||||
warn() { echo "$ICON_WARN [WARN] $*"; }
|
warn() { echo "$ICON_WARN [WARN] $*"; }
|
||||||
@@ -24,7 +26,7 @@ log() {
|
|||||||
[[ "${ENABLE_LOGGING:-false}" == true ]] && echo "[LOG] $*"
|
[[ "${ENABLE_LOGGING:-false}" == true ]] && echo "[LOG] $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Args -----------------------------
|
# ----------------------------- ARG PARSER -----------------------------
|
||||||
|
|
||||||
parse_args() {
|
parse_args() {
|
||||||
ENABLE_LOGGING=${ENABLE_LOGGING:-false}
|
ENABLE_LOGGING=${ENABLE_LOGGING:-false}
|
||||||
@@ -70,13 +72,13 @@ parse_args() {
|
|||||||
PARSED_ARGS=("${CLEAN_ARGS[@]}")
|
PARSED_ARGS=("${CLEAN_ARGS[@]}")
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Validation -----------------------------
|
# ----------------------------- VALIDATION -----------------------------
|
||||||
|
|
||||||
require_var() {
|
require_var() {
|
||||||
[[ -z "${!1:-}" ]] && error "Missing required: $1" && exit 1
|
[[ -z "${!1:-}" ]] && error "Missing required: $1" && exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Host Detection -----------------------------
|
# ----------------------------- HOST DETECTION -----------------------------
|
||||||
|
|
||||||
detect_hosts() {
|
detect_hosts() {
|
||||||
LOCAL_HOSTNAME="$(hostname)"
|
LOCAL_HOSTNAME="$(hostname)"
|
||||||
@@ -103,7 +105,7 @@ detect_hosts() {
|
|||||||
info "Host: $LOCAL_SERVER_NAME → $REMOTE_SERVER_NAME"
|
info "Host: $LOCAL_SERVER_NAME → $REMOTE_SERVER_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Remote -----------------------------
|
# ----------------------------- REMOTE -----------------------------
|
||||||
|
|
||||||
resolve_remote_ip() {
|
resolve_remote_ip() {
|
||||||
log "Resolving remote IP..."
|
log "Resolving remote IP..."
|
||||||
@@ -114,7 +116,7 @@ resolve_remote_ip() {
|
|||||||
info "Remote IP: $REMOTE_SERVER"
|
info "Remote IP: $REMOTE_SERVER"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Containers -----------------------------
|
# ----------------------------- CONTAINERS -----------------------------
|
||||||
|
|
||||||
RUNNING_CONTAINERS=()
|
RUNNING_CONTAINERS=()
|
||||||
|
|
||||||
@@ -147,7 +149,7 @@ start_containers() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- RSYNC LIMITER (FIX ADDED) -----------------------------
|
# ----------------------------- RSYNC LIMITER (FIXED FINAL) -----------------------------
|
||||||
|
|
||||||
wait_for_rsync() {
|
wait_for_rsync() {
|
||||||
: "${RETRY_COUNT:=5}"
|
: "${RETRY_COUNT:=5}"
|
||||||
@@ -155,7 +157,9 @@ wait_for_rsync() {
|
|||||||
: "${SLEEP:=2}"
|
: "${SLEEP:=2}"
|
||||||
|
|
||||||
for i in $(seq 1 "$RETRY_COUNT"); do
|
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
|
if [[ "$COUNT" -ge "$MAX_RSYNC_PROCS" ]]; then
|
||||||
warn "Waiting rsync slot ($COUNT/$MAX_RSYNC_PROCS)"
|
warn "Waiting rsync slot ($COUNT/$MAX_RSYNC_PROCS)"
|
||||||
|
|||||||
Reference in New Issue
Block a user