added status

This commit is contained in:
2026-03-25 01:54:51 +00:00
parent ce1eed3b8b
commit 3cc2796caa
2 changed files with 38 additions and 8 deletions
+7
View File
@@ -32,6 +32,13 @@ RETRY_COUNT=${PROFILE_RETRY_COUNT[$PROFILE_NAME]:-$RETRY_COUNT}
SLEEP=${PROFILE_SLEEP[$PROFILE_NAME]:-$SLEEP} SLEEP=${PROFILE_SLEEP[$PROFILE_NAME]:-$SLEEP}
EXCLUDE_DIRS=(${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-${EXCLUDE_DIRS[@]}}) EXCLUDE_DIRS=(${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-${EXCLUDE_DIRS[@]}})
# ----------------------------- Status Mode -----------------------------
if [[ "$SHOW_STATUS" == true ]]; then
show_status
exit 0
fi
# ----------------------------- User Info ----------------------------- # ----------------------------- User Info -----------------------------
echo "============================================================" echo "============================================================"
echo " Sync Job Starting" echo " Sync Job Starting"
+31 -8
View File
@@ -4,7 +4,6 @@
# ----------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------
# ----------------------------- Output Helpers ----------------------------- # ----------------------------- Output Helpers -----------------------------
info() { info() {
echo "[INFO] $*" echo "[INFO] $*"
} }
@@ -22,7 +21,6 @@ log() {
} }
# ----------------------------- Argument Parsing ----------------------------- # ----------------------------- Argument Parsing -----------------------------
parse_args() { parse_args() {
DRY_RUN=${DRY_RUN:-false} DRY_RUN=${DRY_RUN:-false}
ENABLE_LOGGING=${ENABLE_LOGGING:-false} ENABLE_LOGGING=${ENABLE_LOGGING:-false}
@@ -66,6 +64,10 @@ parse_args() {
--no-log) --no-log)
ENABLE_LOGGING=false ENABLE_LOGGING=false
;; ;;
--status|--summary)
SHOW_STATUS=true
;;
;;
--help|-h) --help|-h)
echo "Usage: script <dir> [--dry-run|-n] [--log] [LOG=true] [VAR=value ...]" echo "Usage: script <dir> [--dry-run|-n] [--log] [LOG=true] [VAR=value ...]"
exit 0 exit 0
@@ -79,7 +81,6 @@ parse_args() {
} }
# ----------------------------- Validation ----------------------------- # ----------------------------- Validation -----------------------------
require_var() { require_var() {
local var="$1" local var="$1"
if [[ -z "${!var:-}" ]]; then if [[ -z "${!var:-}" ]]; then
@@ -99,7 +100,6 @@ validate_int() {
} }
# ----------------------------- Host Detection ----------------------------- # ----------------------------- Host Detection -----------------------------
detect_hosts() { detect_hosts() {
LOCAL_HOSTNAME="$(hostname)" LOCAL_HOSTNAME="$(hostname)"
@@ -131,7 +131,6 @@ detect_hosts() {
} }
# ----------------------------- Remote IP ----------------------------- # ----------------------------- Remote IP -----------------------------
resolve_remote_ip() { resolve_remote_ip() {
log "Resolving Tailscale IP for $REMOTE_SERVER_NAME..." log "Resolving Tailscale IP for $REMOTE_SERVER_NAME..."
@@ -146,14 +145,12 @@ resolve_remote_ip() {
} }
# ----------------------------- Connectivity ----------------------------- # ----------------------------- Connectivity -----------------------------
check_remote_online() { check_remote_online() {
log "Pinging $REMOTE_SERVER..." log "Pinging $REMOTE_SERVER..."
ping -c 1 "$REMOTE_SERVER" &>/dev/null ping -c 1 "$REMOTE_SERVER" &>/dev/null
} }
# ----------------------------- Containers ----------------------------- # ----------------------------- Containers -----------------------------
declare -a RUNNING_CONTAINERS=() declare -a RUNNING_CONTAINERS=()
stop_containers() { stop_containers() {
@@ -201,7 +198,6 @@ start_containers() {
} }
# ----------------------------- Rsync Options ----------------------------- # ----------------------------- Rsync Options -----------------------------
get_rsync_opts() { get_rsync_opts() {
if [[ -n "${PROFILE_RSYNC_OPTS[$PROFILE_NAME]:-}" ]]; then if [[ -n "${PROFILE_RSYNC_OPTS[$PROFILE_NAME]:-}" ]]; then
read -r -a RSYNC_OPTS <<< "${PROFILE_RSYNC_OPTS[$PROFILE_NAME]}" read -r -a RSYNC_OPTS <<< "${PROFILE_RSYNC_OPTS[$PROFILE_NAME]}"
@@ -210,4 +206,31 @@ get_rsync_opts() {
RSYNC_OPTS=("${DEFAULT_RSYNC_OPTS[@]}") RSYNC_OPTS=("${DEFAULT_RSYNC_OPTS[@]}")
log "Using default rsync options: ${DEFAULT_RSYNC_OPTS[*]}" log "Using default rsync options: ${DEFAULT_RSYNC_OPTS[*]}"
fi 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 "========================="
} }