improved progress

This commit is contained in:
2026-03-27 20:39:58 +00:00
parent 1dd8a36ad0
commit 3b7476ff97
2 changed files with 23 additions and 12 deletions
+2
View File
@@ -34,6 +34,8 @@ SSH_KEY="/root/.ssh/id_gitea_rsync"
SSH_PORT=221 SSH_PORT=221
# -------------------Rsync Script Defaults----------------------- # -------------------Rsync Script Defaults-----------------------
# turns on or off progress info for rsync
ENABLE_PROGRESS=true
# Network speed limit (KB/s) # Network speed limit (KB/s)
BW_LIMIT=12500 BW_LIMIT=12500
# Retry logic # Retry logic
+21 -12
View File
@@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
# ----------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------
# ----------------- UNRAID OPS COMMON LIBRARY (STABLE FRAMEWORK v1) ----------------------- # ----------------- UNRAID OPS COMMON LIBRARY (FINAL STABLE FRAMEWORK v1) -----------------------
# ----------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------
# ICONS Profiles # ----------------------------- ICONS -----------------------------
ICON_INFO="️" ICON_INFO="️"
ICON_WARN="⚠️" ICON_WARN="⚠️"
ICON_ERROR="❌" ICON_ERROR="❌"
@@ -14,7 +14,7 @@ ICON_RETRY="🔁"
ICON_SYNC="🔄" ICON_SYNC="🔄"
ICON_GEAR="⚙️" ICON_GEAR="⚙️"
# OUTPUT # ----------------------------- OUTPUT -----------------------------
info() { echo "$ICON_INFO [INFO] $*"; } info() { echo "$ICON_INFO [INFO] $*"; }
warn() { echo "$ICON_WARN [WARN] $*"; } warn() { echo "$ICON_WARN [WARN] $*"; }
error() { echo "$ICON_ERROR [ERROR] $*"; } error() { echo "$ICON_ERROR [ERROR] $*"; }
@@ -24,7 +24,7 @@ log() {
[[ "${ENABLE_LOGGING:-false}" == true ]] && echo "[LOG] $*" [[ "${ENABLE_LOGGING:-false}" == true ]] && echo "[LOG] $*"
} }
# ARG PARSER # ----------------------------- ARG PARSER -----------------------------
parse_args() { parse_args() {
ENABLE_LOGGING=${ENABLE_LOGGING:-false} ENABLE_LOGGING=${ENABLE_LOGGING:-false}
DRY_RUN=${DRY_RUN:-false} DRY_RUN=${DRY_RUN:-false}
@@ -69,12 +69,12 @@ parse_args() {
PARSED_ARGS=("${CLEAN_ARGS[@]}") PARSED_ARGS=("${CLEAN_ARGS[@]}")
} }
# VALIDATION # ----------------------------- VALIDATION -----------------------------
require_var() { require_var() {
[[ -z "${!1:-}" ]] && error "Missing required: $1" && exit 1 [[ -z "${!1:-}" ]] && error "Missing required: $1" && exit 1
} }
# HOST DETECTION # ----------------------------- HOST DETECTION -----------------------------
detect_hosts() { detect_hosts() {
LOCAL_HOSTNAME="$(hostname)" LOCAL_HOSTNAME="$(hostname)"
@@ -100,7 +100,7 @@ detect_hosts() {
info "Host: $LOCAL_SERVER_NAME$REMOTE_SERVER_NAME" info "Host: $LOCAL_SERVER_NAME$REMOTE_SERVER_NAME"
} }
# REMOTE # ----------------------------- REMOTE -----------------------------
resolve_remote_ip() { resolve_remote_ip() {
log "Resolving remote IP..." log "Resolving remote IP..."
REMOTE_SERVER=$(tailscale ip -4 "$REMOTE_SERVER_NAME" 2>/dev/null) REMOTE_SERVER=$(tailscale ip -4 "$REMOTE_SERVER_NAME" 2>/dev/null)
@@ -110,7 +110,7 @@ resolve_remote_ip() {
info "Remote IP: $REMOTE_SERVER" info "Remote IP: $REMOTE_SERVER"
} }
# CONTAINERS # ----------------------------- CONTAINERS -----------------------------
RUNNING_CONTAINERS=() RUNNING_CONTAINERS=()
stop_containers() { stop_containers() {
@@ -156,7 +156,7 @@ start_containers() {
done done
} }
# RSYNC LIMITER # ----------------------------- RSYNC LIMITER -----------------------------
wait_for_rsync() { wait_for_rsync() {
: "${RETRY_COUNT:=5}" : "${RETRY_COUNT:=5}"
: "${MAX_RSYNC_PROCS:=2}" : "${MAX_RSYNC_PROCS:=2}"
@@ -182,17 +182,25 @@ wait_for_rsync() {
exit 1 exit 1
} }
# 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]}"
log "Using profile rsync opts"
else else
RSYNC_OPTS=("${DEFAULT_RSYNC_OPTS[@]}") RSYNC_OPTS=("${DEFAULT_RSYNC_OPTS[@]}")
RSYNC_OPTS+=(--info=progress2) log "Using default rsync opts"
fi
# ------------------ PROGRESS (SAFE TOGGLE) ------------------
if [[ "${ENABLE_PROGRESS:-false}" == true ]]; then
RSYNC_OPTS+=(--info=progress2 --human-readable)
log "Progress enabled (progress2 + human-readable)"
fi fi
} }
# STATUS # ----------------------------- STATUS -----------------------------
show_status() { show_status() {
echo "===== STATUS =====" echo "===== STATUS ====="
echo "Local: $LOCAL_SERVER_NAME" echo "Local: $LOCAL_SERVER_NAME"
@@ -201,5 +209,6 @@ show_status() {
echo "Profile: $PROFILE_NAME" echo "Profile: $PROFILE_NAME"
echo "DryRun: $DRY_RUN" echo "DryRun: $DRY_RUN"
echo "Logging: $ENABLE_LOGGING" echo "Logging: $ENABLE_LOGGING"
echo "Progress:${ENABLE_PROGRESS:-false}"
echo "==================" echo "=================="
} }