FRAMEWORK TWEAK

This commit is contained in:
2026-03-27 17:14:57 +00:00
parent 2fe53efaa6
commit 4fffcfea51
2 changed files with 83 additions and 161 deletions
+36 -17
View File
@@ -10,6 +10,7 @@ source "$SCRIPT_DIR/../Master.conf"
source "$SCRIPT_DIR/../common.sh"
# ----------------------------- INIT -----------------------------
parse_args "$@"
require_var "HOST1"
@@ -18,47 +19,61 @@ require_var "HOST2"
detect_hosts
resolve_remote_ip
# ----------------------------- POSITIONAL MAPPING -----------------------------
# ----------------------------- POSITIONAL -----------------------------
SOURCE="${POSITIONAL_ARGS[0]:-}"
DEST="${POSITIONAL_ARGS[1]:-}"
# ----------------------------- STATUS MODE -----------------------------
if [[ "$SHOW_STATUS" == true ]]; then
show_status
exit 0
fi
# ----------------------------- HEADER -----------------------------
ui_header "RSYNC OPERATION"
ui_section "Context"
ui_kv "Source" "$SOURCE"
ui_kv "Destination" "$DEST"
ui_kv "Remote" "$REMOTE_SERVER_NAME"
ui_kv "IP" "$REMOTE_SERVER"
ui_kv "Dry Run" "$DRY_RUN"
echo
echo "=================================================="
echo " 🚀 RSYNC START"
echo "=================================================="
echo "[INFO] Source: $SOURCE"
echo "[INFO] Destination: $DEST"
echo "[INFO] Remote: $REMOTE_SERVER_NAME ($REMOTE_SERVER)"
echo "[INFO] DryRun: $DRY_RUN"
echo
# ----------------------------- VALIDATION -----------------------------
if [[ -z "$SOURCE" ]]; then
ui_status error "Missing SOURCE (arg 1)"
echo_error "Missing SOURCE"
exit 1
fi
if [[ -z "$DEST" ]]; then
ui_status error "Missing DEST (arg 2)"
echo_error "Missing DEST"
exit 1
fi
ui_status ok "Validation passed"
echo "[OK] Validation passed"
log "Validation completed successfully"
# ----------------------------- PRECHECK -----------------------------
if ! check_remote_online; then
ui_status error "Remote offline"
echo_error "Remote host offline"
exit 1
fi
# ----------------------------- EXECUTION -----------------------------
echo "[OK] Remote reachable"
# ----------------------------- CONTAINERS -----------------------------
stop_containers
# ----------------------------- RSYNC -----------------------------
get_rsync_opts
RSYNC_CMD=(
@@ -72,15 +87,19 @@ if [[ "$DRY_RUN" == true ]]; then
RSYNC_CMD+=("--dry-run")
fi
ui_section "Execution"
ui_status ok "Running rsync"
echo
echo "[RUN] Executing rsync..."
log "CMD: ${RSYNC_CMD[*]}"
"${RSYNC_CMD[@]}"
# ----------------------------- RECOVERY -----------------------------
start_containers
# ----------------------------- END -----------------------------
ui_footer "RSYNC COMPLETE"
echo
echo "=================================================="
echo " ✅ RSYNC COMPLETE"
echo "=================================================="