improved progress
This commit is contained in:
@@ -34,6 +34,8 @@ SSH_KEY="/root/.ssh/id_gitea_rsync"
|
||||
SSH_PORT=221
|
||||
|
||||
# -------------------Rsync Script Defaults-----------------------
|
||||
# turns on or off progress info for rsync
|
||||
ENABLE_PROGRESS=true
|
||||
# Network speed limit (KB/s)
|
||||
BW_LIMIT=12500
|
||||
# Retry logic
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/bin/bash
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# ----------------- UNRAID OPS COMMON LIBRARY (STABLE FRAMEWORK v1) -----------------------
|
||||
# ----------------- UNRAID OPS COMMON LIBRARY (FINAL STABLE FRAMEWORK v1) -----------------------
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
|
||||
# ICONS Profiles
|
||||
# ----------------------------- ICONS -----------------------------
|
||||
ICON_INFO="ℹ️"
|
||||
ICON_WARN="⚠️"
|
||||
ICON_ERROR="❌"
|
||||
@@ -14,7 +14,7 @@ ICON_RETRY="🔁"
|
||||
ICON_SYNC="🔄"
|
||||
ICON_GEAR="⚙️"
|
||||
|
||||
# OUTPUT
|
||||
# ----------------------------- OUTPUT -----------------------------
|
||||
info() { echo "$ICON_INFO [INFO] $*"; }
|
||||
warn() { echo "$ICON_WARN [WARN] $*"; }
|
||||
error() { echo "$ICON_ERROR [ERROR] $*"; }
|
||||
@@ -24,7 +24,7 @@ log() {
|
||||
[[ "${ENABLE_LOGGING:-false}" == true ]] && echo "[LOG] $*"
|
||||
}
|
||||
|
||||
# ARG PARSER
|
||||
# ----------------------------- ARG PARSER -----------------------------
|
||||
parse_args() {
|
||||
ENABLE_LOGGING=${ENABLE_LOGGING:-false}
|
||||
DRY_RUN=${DRY_RUN:-false}
|
||||
@@ -69,12 +69,12 @@ parse_args() {
|
||||
PARSED_ARGS=("${CLEAN_ARGS[@]}")
|
||||
}
|
||||
|
||||
# VALIDATION
|
||||
# ----------------------------- VALIDATION -----------------------------
|
||||
require_var() {
|
||||
[[ -z "${!1:-}" ]] && error "Missing required: $1" && exit 1
|
||||
}
|
||||
|
||||
# HOST DETECTION
|
||||
# ----------------------------- HOST DETECTION -----------------------------
|
||||
detect_hosts() {
|
||||
LOCAL_HOSTNAME="$(hostname)"
|
||||
|
||||
@@ -100,7 +100,7 @@ detect_hosts() {
|
||||
info "Host: $LOCAL_SERVER_NAME → $REMOTE_SERVER_NAME"
|
||||
}
|
||||
|
||||
# REMOTE
|
||||
# ----------------------------- REMOTE -----------------------------
|
||||
resolve_remote_ip() {
|
||||
log "Resolving remote IP..."
|
||||
REMOTE_SERVER=$(tailscale ip -4 "$REMOTE_SERVER_NAME" 2>/dev/null)
|
||||
@@ -110,7 +110,7 @@ resolve_remote_ip() {
|
||||
info "Remote IP: $REMOTE_SERVER"
|
||||
}
|
||||
|
||||
# CONTAINERS
|
||||
# ----------------------------- CONTAINERS -----------------------------
|
||||
RUNNING_CONTAINERS=()
|
||||
|
||||
stop_containers() {
|
||||
@@ -156,7 +156,7 @@ start_containers() {
|
||||
done
|
||||
}
|
||||
|
||||
# RSYNC LIMITER
|
||||
# ----------------------------- RSYNC LIMITER -----------------------------
|
||||
wait_for_rsync() {
|
||||
: "${RETRY_COUNT:=5}"
|
||||
: "${MAX_RSYNC_PROCS:=2}"
|
||||
@@ -182,17 +182,25 @@ wait_for_rsync() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# RSYNC OPTIONS
|
||||
# ----------------------------- RSYNC OPTIONS -----------------------------
|
||||
get_rsync_opts() {
|
||||
|
||||
if [[ -n "${PROFILE_RSYNC_OPTS[$PROFILE_NAME]:-}" ]]; then
|
||||
read -r -a RSYNC_OPTS <<< "${PROFILE_RSYNC_OPTS[$PROFILE_NAME]}"
|
||||
log "Using profile rsync opts"
|
||||
else
|
||||
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
|
||||
}
|
||||
|
||||
# STATUS
|
||||
# ----------------------------- STATUS -----------------------------
|
||||
show_status() {
|
||||
echo "===== STATUS ====="
|
||||
echo "Local: $LOCAL_SERVER_NAME"
|
||||
@@ -201,5 +209,6 @@ show_status() {
|
||||
echo "Profile: $PROFILE_NAME"
|
||||
echo "DryRun: $DRY_RUN"
|
||||
echo "Logging: $ENABLE_LOGGING"
|
||||
echo "Progress:${ENABLE_PROGRESS:-false}"
|
||||
echo "=================="
|
||||
}
|
||||
Reference in New Issue
Block a user