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"
# ----------------------------------------------------------------------------------
# INPUT PARSING (FIXED - positional args + flags separation)
# INPUT PARSING (FIXED)
# ----------------------------------------------------------------------------------
DIRECTORY=""
@@ -49,7 +49,6 @@ parse_args "${RAW_ARGS[@]}"
if [[ -z "$DIRECTORY" ]]; then
error "Missing directory"
echo "Usage: $0 <directory> [--dry-run] [--status] [VAR=value]"
exit 1
fi
@@ -85,22 +84,22 @@ if [[ "${SHOW_STATUS:-false}" == true ]]; then
fi
# ----------------------------------------------------------------------------------
# HEADER
# HEADER (HANDLED IN COMMON OUTPUT LAYER)
# ----------------------------------------------------------------------------------
echo
echo "$ICON_RUN Sync Starting"
echo "Source: $DIRECTORY"
echo "Remote: $REMOTE_SERVER:$DIRECTORY"
echo "Profile: $PROFILE_NAME"
echo "Dry Run: $DRY_RUN"
info "Sync Starting"
info "Source: $DIRECTORY"
info "Remote: $REMOTE_SERVER:$DIRECTORY"
info "Profile: $PROFILE_NAME"
info "Dry Run: $DRY_RUN"
echo "--------------------------------------------"
# ----------------------------------------------------------------------------------
# REMOTE CHECK (FIXED LOGIC)
# REMOTE CHECK
# ----------------------------------------------------------------------------------
echo "$ICON_GEAR Checking remote..."
info "Checking remote..."
REMOTE_OK=false
@@ -121,35 +120,19 @@ if [[ "$REMOTE_OK" != true ]]; then
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
# ----------------------------------------------------------------------------------
# STOP CONTAINERS (FIXED - NO DUPLICATE LOGGING)
# CONTAINERS
# ----------------------------------------------------------------------------------
stop_containers
# ----------------------------------------------------------------------------------
# BUILD RSYNC OPTIONS
# RSYNC OPTIONS
# ----------------------------------------------------------------------------------
get_rsync_opts
@@ -163,11 +146,9 @@ if [[ "$DRY_RUN" == true ]]; then
fi
# ----------------------------------------------------------------------------------
# RSYNC COMMAND (SAFE IMPROVEMENT - NO BEHAVIOR CHANGE)
# RSYNC EXECUTION (NO LOGGING HERE)
# ----------------------------------------------------------------------------------
echo "$ICON_RUN Running rsync..."
RSYNC_CMD=(
rsync
"${RSYNC_OPTS[@]}"
@@ -176,17 +157,9 @@ RSYNC_CMD=(
"root@${REMOTE_SERVER}:$DIRECTORY"
)
log "RSYNC CMD: ${RSYNC_CMD[*]}"
START=$(date +%s)
# ----------------------------------------------------------------------------------
# EXECUTION (RETRY SAFE)
# ----------------------------------------------------------------------------------
for i in $(seq 1 "$RETRY_COUNT"); do
echo "Attempt $i/$RETRY_COUNT"
if "${RSYNC_CMD[@]}"; then
success "Rsync complete"
break
@@ -196,24 +169,17 @@ for i in $(seq 1 "$RETRY_COUNT"); do
fi
done
# ----------------------------------------------------------------------------------
# START CONTAINERS
# ----------------------------------------------------------------------------------
start_containers
# ----------------------------------------------------------------------------------
# SUMMARY
# ----------------------------------------------------------------------------------
END=$(date +%s)
# ----------------------------------------------------------------------------------
# SUMMARY (HANDLED VIA COMMON OUTPUT LAYER ONLY)
# ----------------------------------------------------------------------------------
echo
echo "===== SUMMARY ====="
echo "Directory: $DIRECTORY"
echo "Profile: $PROFILE_NAME"
echo "Duration: $((END-START))s"
echo "Status: DONE"
echo "==================="
✅ WHAT THIS FIX ACTUALLY SOLVES
✔ Removes duplicate:
info "Directory: $DIRECTORY"
info "Profile: $PROFILE_NAME"
info "Duration: $((END-START))s"
info "Status: DONE"
echo "==================="