This commit is contained in:
2026-03-27 18:21:02 +00:00
parent 4887a9c36e
commit e2e628c000
+22 -56
View File
@@ -24,7 +24,7 @@ source "$SCRIPT_DIR/../Master.conf"
source "$SCRIPT_DIR/../common.sh" source "$SCRIPT_DIR/../common.sh"
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
# INPUT PARSING (FIXED - positional args + flags separation) # INPUT PARSING (FIXED)
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
DIRECTORY="" DIRECTORY=""
@@ -49,7 +49,6 @@ parse_args "${RAW_ARGS[@]}"
if [[ -z "$DIRECTORY" ]]; then if [[ -z "$DIRECTORY" ]]; then
error "Missing directory" error "Missing directory"
echo "Usage: $0 <directory> [--dry-run] [--status] [VAR=value]"
exit 1 exit 1
fi fi
@@ -85,22 +84,22 @@ if [[ "${SHOW_STATUS:-false}" == true ]]; then
fi fi
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
# HEADER # HEADER (HANDLED IN COMMON OUTPUT LAYER)
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
echo echo
echo "$ICON_RUN Sync Starting" info "Sync Starting"
echo "Source: $DIRECTORY" info "Source: $DIRECTORY"
echo "Remote: $REMOTE_SERVER:$DIRECTORY" info "Remote: $REMOTE_SERVER:$DIRECTORY"
echo "Profile: $PROFILE_NAME" info "Profile: $PROFILE_NAME"
echo "Dry Run: $DRY_RUN" info "Dry Run: $DRY_RUN"
echo "--------------------------------------------" echo "--------------------------------------------"
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
# REMOTE CHECK (FIXED LOGIC) # REMOTE CHECK
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
echo "$ICON_GEAR Checking remote..." info "Checking remote..."
REMOTE_OK=false REMOTE_OK=false
@@ -121,35 +120,19 @@ if [[ "$REMOTE_OK" != true ]]; then
fi fi
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
# RSYNC SLOT LIMITER # RSYNC LIMITER
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
wait_for_rsync() {
for i in $(seq 1 "$RETRY_COUNT"); do
COUNT=$(pgrep -fc "rsync.*root@${REMOTE_SERVER}" || true)
if [[ "$COUNT" -ge "$MAX_RSYNC_PROCS" ]]; then
warn "Waiting rsync slot ($COUNT)"
sleep "$SLEEP"
else
return 0
fi
done
error "Too many rsync processes"
exit 1
}
wait_for_rsync wait_for_rsync
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
# STOP CONTAINERS (FIXED - NO DUPLICATE LOGGING) # CONTAINERS
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
stop_containers stop_containers
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
# BUILD RSYNC OPTIONS # RSYNC OPTIONS
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
get_rsync_opts get_rsync_opts
@@ -163,11 +146,9 @@ if [[ "$DRY_RUN" == true ]]; then
fi fi
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
# RSYNC COMMAND (SAFE IMPROVEMENT - NO BEHAVIOR CHANGE) # RSYNC EXECUTION (NO LOGGING HERE)
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
echo "$ICON_RUN Running rsync..."
RSYNC_CMD=( RSYNC_CMD=(
rsync rsync
"${RSYNC_OPTS[@]}" "${RSYNC_OPTS[@]}"
@@ -176,17 +157,9 @@ RSYNC_CMD=(
"root@${REMOTE_SERVER}:$DIRECTORY" "root@${REMOTE_SERVER}:$DIRECTORY"
) )
log "RSYNC CMD: ${RSYNC_CMD[*]}"
START=$(date +%s) START=$(date +%s)
# ----------------------------------------------------------------------------------
# EXECUTION (RETRY SAFE)
# ----------------------------------------------------------------------------------
for i in $(seq 1 "$RETRY_COUNT"); do for i in $(seq 1 "$RETRY_COUNT"); do
echo "Attempt $i/$RETRY_COUNT"
if "${RSYNC_CMD[@]}"; then if "${RSYNC_CMD[@]}"; then
success "Rsync complete" success "Rsync complete"
break break
@@ -196,24 +169,17 @@ for i in $(seq 1 "$RETRY_COUNT"); do
fi fi
done done
# ----------------------------------------------------------------------------------
# START CONTAINERS
# ----------------------------------------------------------------------------------
start_containers start_containers
# ----------------------------------------------------------------------------------
# SUMMARY
# ----------------------------------------------------------------------------------
END=$(date +%s) END=$(date +%s)
# ----------------------------------------------------------------------------------
# SUMMARY (HANDLED VIA COMMON OUTPUT LAYER ONLY)
# ----------------------------------------------------------------------------------
echo echo
echo "===== SUMMARY =====" info "Directory: $DIRECTORY"
echo "Directory: $DIRECTORY" info "Profile: $PROFILE_NAME"
echo "Profile: $PROFILE_NAME" info "Duration: $((END-START))s"
echo "Duration: $((END-START))s" info "Status: DONE"
echo "Status: DONE" echo "==================="
echo "==================="
✅ WHAT THIS FIX ACTUALLY SOLVES
✔ Removes duplicate: