moved some things to common.sh
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# ----------------- UNRAID OPS COMMON LIBRARY (STABLE FRAMEWORK v1) ----------------------------
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# Version: 1.1
|
||||
# Changed: format_duration moved here from daily_sync.sh for shared use
|
||||
# SSH_KEY collision documented — gitea key renamed GITEA_SSH_KEY in Master.conf
|
||||
# Version and changelog tracking added
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
|
||||
# ICONS
|
||||
ICON_INFO="ℹ️"
|
||||
@@ -24,6 +29,18 @@ log() {
|
||||
[[ "${ENABLE_LOGGING:-false}" == true ]] && echo "[LOG] $*"
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# DURATION FORMATTER
|
||||
# Converts raw seconds to human readable format — e.g. 10m53s or 47s
|
||||
# Used by rsync.sh and daily_sync.sh
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
format_duration() {
|
||||
local secs=$1
|
||||
local mins=$((secs / 60))
|
||||
local rem=$((secs % 60))
|
||||
[[ $mins -gt 0 ]] && echo "${mins}m${rem}s" || echo "${rem}s"
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# ARG PARSER
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
@@ -118,6 +135,20 @@ resolve_remote_ip() {
|
||||
info "Remote IP: $REMOTE_SERVER"
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# CONNECTIVITY CHECK
|
||||
# Verifies remote is reachable before attempting rsync.
|
||||
# Prevents retry loop burning all attempts against an unreachable host.
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
check_connectivity() {
|
||||
log "Checking connectivity to $REMOTE_SERVER..."
|
||||
if ! ping -c1 -W3 "$REMOTE_SERVER" &>/dev/null; then
|
||||
error "Remote $REMOTE_SERVER is unreachable — aborting"
|
||||
exit 1
|
||||
fi
|
||||
log "Remote is reachable"
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# CONTAINERS
|
||||
# CRITICAL_CONTAINER_NAMES and DELAYED_CONTAINERS must be bash arrays before calling these.
|
||||
|
||||
Reference in New Issue
Block a user