This commit is contained in:
2026-03-27 18:27:04 +00:00
parent e2e628c000
commit fb6c76eb92
2 changed files with 61 additions and 104 deletions
+10 -68
View File
@@ -23,81 +23,53 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../Master.conf"
source "$SCRIPT_DIR/../common.sh"
# ----------------------------------------------------------------------------------
# INPUT PARSING (FIXED)
# ----------------------------------------------------------------------------------
# ----------------------------- INPUT -----------------------------
DIRECTORY=""
RAW_ARGS=()
for ARG in "$@"; do
case "$ARG" in
--*|*=*)
RAW_ARGS+=("$ARG")
;;
--*|*=*) RAW_ARGS+=("$ARG") ;;
*)
if [[ -z "$DIRECTORY" ]]; then
DIRECTORY="$ARG"
else
RAW_ARGS+=("$ARG")
fi
;;
;;
esac
done
parse_args "${RAW_ARGS[@]}"
if [[ -z "$DIRECTORY" ]]; then
error "Missing directory"
exit 1
fi
[[ -z "$DIRECTORY" ]] && error "Missing directory" && exit 1
# ----------------------------------------------------------------------------------
# HOST SETUP
# ----------------------------------------------------------------------------------
# ----------------------------- CORE -----------------------------
detect_hosts
resolve_remote_ip
# ----------------------------------------------------------------------------------
# PROFILE SETUP
# ----------------------------------------------------------------------------------
PROFILE_NAME=$(basename "$DIRECTORY" | tr '[:upper:]' '[:lower:]')
MAX_RSYNC_PROCS=${PROFILE_MAX_PROCS[$PROFILE_NAME]:-$MAX_RSYNC_PROCS}
BW_LIMIT=${PROFILE_BW_LIMIT[$PROFILE_NAME]:-$BW_LIMIT}
CRITICAL_CONTAINER_NAMES=(${PROFILE_CRITICAL_CONTAINER_NAMES[$PROFILE_NAME]})
DELAYED_CONTAINERS=(${PROFILE_DELAYED_CONTAINERS[$PROFILE_NAME]})
CONTAINER_DELAY=${PROFILE_CONTAINER_DELAY[$PROFILE_NAME]:-$CONTAINER_DELAY}
RETRY_COUNT=${PROFILE_RETRY_COUNT[$PROFILE_NAME]:-$RETRY_COUNT}
SLEEP=${PROFILE_SLEEP[$PROFILE_NAME]:-$SLEEP}
EXCLUDE_DIRS=(${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-${EXCLUDE_DIRS[@]}})
# ----------------------------------------------------------------------------------
# STATUS MODE
# ----------------------------------------------------------------------------------
# ----------------------------- STATUS -----------------------------
if [[ "${SHOW_STATUS:-false}" == true ]]; then
show_status
exit 0
fi
# ----------------------------------------------------------------------------------
# HEADER (HANDLED IN COMMON OUTPUT LAYER)
# ----------------------------------------------------------------------------------
# ----------------------------- FLOW -----------------------------
echo
info "Sync Starting"
info "Source: $DIRECTORY"
info "Remote: $REMOTE_SERVER:$DIRECTORY"
info "Profile: $PROFILE_NAME"
info "Dry Run: $DRY_RUN"
echo "--------------------------------------------"
# ----------------------------------------------------------------------------------
# REMOTE CHECK
# ----------------------------------------------------------------------------------
info "Checking remote..."
@@ -109,45 +81,21 @@ for i in $(seq 1 "$RETRY_COUNT"); do
REMOTE_OK=true
break
fi
warn "Retry $i/$RETRY_COUNT"
sleep "$SLEEP"
done
if [[ "$REMOTE_OK" != true ]]; then
error "Remote unreachable"
exit 1
fi
# ----------------------------------------------------------------------------------
# RSYNC LIMITER
# ----------------------------------------------------------------------------------
[[ "$REMOTE_OK" != true ]] && error "Remote unreachable" && exit 1
wait_for_rsync
# ----------------------------------------------------------------------------------
# CONTAINERS
# ----------------------------------------------------------------------------------
stop_containers
# ----------------------------------------------------------------------------------
# RSYNC OPTIONS
# ----------------------------------------------------------------------------------
get_rsync_opts
for ex in "${EXCLUDE_DIRS[@]}"; do
RSYNC_OPTS+=(--exclude="$ex")
done
if [[ "$DRY_RUN" == true ]]; then
RSYNC_OPTS+=("--dry-run")
fi
# ----------------------------------------------------------------------------------
# RSYNC EXECUTION (NO LOGGING HERE)
# ----------------------------------------------------------------------------------
[[ "$DRY_RUN" == true ]] && RSYNC_OPTS+=("--dry-run")
RSYNC_CMD=(
rsync
@@ -173,13 +121,7 @@ start_containers
END=$(date +%s)
# ----------------------------------------------------------------------------------
# SUMMARY (HANDLED VIA COMMON OUTPUT LAYER ONLY)
# ----------------------------------------------------------------------------------
echo
info "Directory: $DIRECTORY"
info "Profile: $PROFILE_NAME"
info "Duration: $((END-START))s"
info "Status: DONE"
echo "==================="
info "Status: DONE"