added status
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------- Output Helpers -----------------------------
|
||||
|
||||
info() {
|
||||
echo "[INFO] $*"
|
||||
}
|
||||
@@ -22,7 +21,6 @@ log() {
|
||||
}
|
||||
|
||||
# ----------------------------- Argument Parsing -----------------------------
|
||||
|
||||
parse_args() {
|
||||
DRY_RUN=${DRY_RUN:-false}
|
||||
ENABLE_LOGGING=${ENABLE_LOGGING:-false}
|
||||
@@ -66,6 +64,10 @@ parse_args() {
|
||||
--no-log)
|
||||
ENABLE_LOGGING=false
|
||||
;;
|
||||
--status|--summary)
|
||||
SHOW_STATUS=true
|
||||
;;
|
||||
;;
|
||||
--help|-h)
|
||||
echo "Usage: script <dir> [--dry-run|-n] [--log] [LOG=true] [VAR=value ...]"
|
||||
exit 0
|
||||
@@ -79,7 +81,6 @@ parse_args() {
|
||||
}
|
||||
|
||||
# ----------------------------- Validation -----------------------------
|
||||
|
||||
require_var() {
|
||||
local var="$1"
|
||||
if [[ -z "${!var:-}" ]]; then
|
||||
@@ -99,7 +100,6 @@ validate_int() {
|
||||
}
|
||||
|
||||
# ----------------------------- Host Detection -----------------------------
|
||||
|
||||
detect_hosts() {
|
||||
LOCAL_HOSTNAME="$(hostname)"
|
||||
|
||||
@@ -131,7 +131,6 @@ detect_hosts() {
|
||||
}
|
||||
|
||||
# ----------------------------- Remote IP -----------------------------
|
||||
|
||||
resolve_remote_ip() {
|
||||
log "Resolving Tailscale IP for $REMOTE_SERVER_NAME..."
|
||||
|
||||
@@ -146,14 +145,12 @@ resolve_remote_ip() {
|
||||
}
|
||||
|
||||
# ----------------------------- Connectivity -----------------------------
|
||||
|
||||
check_remote_online() {
|
||||
log "Pinging $REMOTE_SERVER..."
|
||||
ping -c 1 "$REMOTE_SERVER" &>/dev/null
|
||||
}
|
||||
|
||||
# ----------------------------- Containers -----------------------------
|
||||
|
||||
declare -a RUNNING_CONTAINERS=()
|
||||
|
||||
stop_containers() {
|
||||
@@ -201,7 +198,6 @@ start_containers() {
|
||||
}
|
||||
|
||||
# ----------------------------- Rsync Options -----------------------------
|
||||
|
||||
get_rsync_opts() {
|
||||
if [[ -n "${PROFILE_RSYNC_OPTS[$PROFILE_NAME]:-}" ]]; then
|
||||
read -r -a RSYNC_OPTS <<< "${PROFILE_RSYNC_OPTS[$PROFILE_NAME]}"
|
||||
@@ -210,4 +206,31 @@ get_rsync_opts() {
|
||||
RSYNC_OPTS=("${DEFAULT_RSYNC_OPTS[@]}")
|
||||
log "Using default rsync options: ${DEFAULT_RSYNC_OPTS[*]}"
|
||||
fi
|
||||
}
|
||||
|
||||
# ----------------------------- Status Output -----------------------------
|
||||
show_status() {
|
||||
echo "===== RSYNC STATUS ====="
|
||||
echo "Local: $LOCAL_SERVER_NAME"
|
||||
echo "Remote: $REMOTE_SERVER_NAME"
|
||||
echo "Remote IP: $REMOTE_SERVER"
|
||||
echo "SSH Key: $SSH_KEY"
|
||||
echo
|
||||
echo "Directory: $DIRECTORY"
|
||||
echo "Profile: $PROFILE_NAME"
|
||||
echo
|
||||
echo "Max Procs: $MAX_RSYNC_PROCS"
|
||||
echo "Bandwidth: $BW_LIMIT KB/s"
|
||||
echo "Retries: $RETRY_COUNT"
|
||||
echo "Sleep: $SLEEP"
|
||||
echo "Dry Run: $DRY_RUN"
|
||||
echo
|
||||
echo "Containers: ${CRITICAL_CONTAINER_NAMES[*]:-(none)}"
|
||||
echo "Delayed: ${DELAYED_CONTAINERS[*]:-(none)}"
|
||||
echo
|
||||
echo "Excludes: ${EXCLUDE_DIRS[*]:-(none)}"
|
||||
echo
|
||||
echo "Rsync Opts:"
|
||||
printf ' %s\n' "${RSYNC_OPTS[@]}"
|
||||
echo "========================="
|
||||
}
|
||||
Reference in New Issue
Block a user