added ui icon system

This commit is contained in:
2026-03-27 17:04:08 +00:00
parent 4faf5d2b96
commit 2fe53efaa6
2 changed files with 232 additions and 135 deletions
+64 -71
View File
@@ -9,85 +9,78 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../Master.conf"
source "$SCRIPT_DIR/../common.sh"
# ----------------------------- INIT -----------------------------
parse_args "$@"
# STATUS MODE
require_var "HOST1"
require_var "HOST2"
detect_hosts
resolve_remote_ip
# ----------------------------- POSITIONAL MAPPING -----------------------------
SOURCE="${POSITIONAL_ARGS[0]:-}"
DEST="${POSITIONAL_ARGS[1]:-}"
# ----------------------------- STATUS MODE -----------------------------
if [[ "$SHOW_STATUS" == true ]]; then
echo
echo "=================================================="
echo " ️ RSYNC STOP STATUS"
echo "--------------------------------------------------"
echo " 🔄 Target: rsync processes"
echo " 🧪 Dry Run: $DRY_RUN"
echo "=================================================="
show_status
exit 0
fi
# HEADER
echo
echo "============================================================"
echo " 🚀 RSYNC STOP STARTING"
echo "------------------------------------------------------------"
echo " 🔄 Target: all rsync processes"
echo " 🧪 Dry Run: $DRY_RUN"
echo "============================================================"
# ----------------------------- HEADER -----------------------------
ui_header "RSYNC OPERATION"
log "️ Checking for running rsync processes"
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"
# FUNCTIONS
check_rsync_running() {
pgrep -f rsync >/dev/null 2>&1
}
stop_rsync_processes() {
if [[ "$DRY_RUN" == true ]]; then
warn "🧪 Would stop all rsync processes"
return
fi
if check_rsync_running; then
info "🟡 Stopping rsync processes"
# safer than blind pkill message-only:
pkill -f rsync
sleep 1
if check_rsync_running; then
warn "🟡 Some rsync processes may still be running"
else
info "🟢 All rsync processes stopped successfully"
fi
else
info "🟢 No rsync processes currently running"
fi
}
# EXECUTION
START_TIME=$(date +%s)
stop_rsync_processes
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
# SUMMARY
echo
echo "============================================================"
if check_rsync_running; then
echo " 🟡 RSYNC STOP SUMMARY"
echo "------------------------------------------------------------"
echo " 🔄 Status: 🟡 SOME PROCESSES MAY REMAIN"
echo " ⏱ Duration: ${DURATION}s"
else
echo " 🟢 RSYNC STOP SUMMARY"
echo "------------------------------------------------------------"
echo " 🔄 Status: 🟢 ALL STOPPED"
echo " ⏱ Duration: ${DURATION}s"
# ----------------------------- VALIDATION -----------------------------
if [[ -z "$SOURCE" ]]; then
ui_status error "Missing SOURCE (arg 1)"
exit 1
fi
echo "============================================================"
if [[ -z "$DEST" ]]; then
ui_status error "Missing DEST (arg 2)"
exit 1
fi
info "️ Rsync stop operation complete"
ui_status ok "Validation passed"
# ----------------------------- PRECHECK -----------------------------
if ! check_remote_online; then
ui_status error "Remote offline"
exit 1
fi
# ----------------------------- EXECUTION -----------------------------
stop_containers
get_rsync_opts
RSYNC_CMD=(
rsync
"${RSYNC_OPTS[@]}"
"$SOURCE"
root@"$REMOTE_SERVER":"$DEST"
)
if [[ "$DRY_RUN" == true ]]; then
RSYNC_CMD+=("--dry-run")
fi
ui_section "Execution"
ui_status ok "Running rsync"
log "CMD: ${RSYNC_CMD[*]}"
"${RSYNC_CMD[@]}"
# ----------------------------- RECOVERY -----------------------------
start_containers
# ----------------------------- END -----------------------------
ui_footer "RSYNC COMPLETE"