Stable v1 framework

This commit is contained in:
2026-03-27 19:29:41 +00:00
parent 2e7f624e11
commit 0e1bb83ef1
2 changed files with 19 additions and 29 deletions
+8 -8
View File
@@ -23,7 +23,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../Master.conf" source "$SCRIPT_DIR/../Master.conf"
source "$SCRIPT_DIR/../common.sh" source "$SCRIPT_DIR/../common.sh"
# ----------------------------- ARG PARSING FIX ----------------------------- # ARG PARSING FIX
DIRECTORY="" DIRECTORY=""
RAW_ARGS=() RAW_ARGS=()
@@ -42,11 +42,11 @@ parse_args "${RAW_ARGS[@]}"
[[ -z "$DIRECTORY" ]] && error "Missing directory" && exit 1 [[ -z "$DIRECTORY" ]] && error "Missing directory" && exit 1
# ----------------------------- HOST ----------------------------- # HOST
detect_hosts detect_hosts
resolve_remote_ip resolve_remote_ip
# ----------------------------- PROFILE ----------------------------- # PROFILE
PROFILE_NAME=$(basename "$DIRECTORY" | tr '[:upper:]' '[:lower:]') PROFILE_NAME=$(basename "$DIRECTORY" | tr '[:upper:]' '[:lower:]')
MAX_RSYNC_PROCS=${PROFILE_MAX_PROCS[$PROFILE_NAME]:-$MAX_RSYNC_PROCS} MAX_RSYNC_PROCS=${PROFILE_MAX_PROCS[$PROFILE_NAME]:-$MAX_RSYNC_PROCS}
@@ -58,13 +58,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 ----------------------------- # STATUS
if [[ "${SHOW_STATUS:-false}" == true ]]; then if [[ "${SHOW_STATUS:-false}" == true ]]; then
show_status show_status
exit 0 exit 0
fi fi
# ----------------------------- HEADER ----------------------------- # HEADER
echo echo
echo "$ICON_RUN Sync Starting" echo "$ICON_RUN Sync Starting"
echo "Source: $DIRECTORY" echo "Source: $DIRECTORY"
@@ -72,7 +72,7 @@ echo "Remote: $REMOTE_SERVER:$DIRECTORY"
echo "Profile: $PROFILE_NAME" echo "Profile: $PROFILE_NAME"
echo "Dry Run: $DRY_RUN" echo "Dry Run: $DRY_RUN"
# ----------------------------- REMOTE CHECK FIX ----------------------------- # REMOTE CHECK FIX
echo "$ICON_GEAR Checking remote..." echo "$ICON_GEAR Checking remote..."
REMOTE_OK=false REMOTE_OK=false
@@ -92,7 +92,7 @@ if [[ "$REMOTE_OK" != true ]]; then
exit 1 exit 1
fi fi
# ----------------------------- RSYNC LIMIT ----------------------------- # RSYNC LIMIT
wait_for_rsync() { wait_for_rsync() {
for i in $(seq 1 "$RETRY_COUNT"); do for i in $(seq 1 "$RETRY_COUNT"); do
COUNT=$(pgrep -fc "rsync.*root@${REMOTE_SERVER}" || true) COUNT=$(pgrep -fc "rsync.*root@${REMOTE_SERVER}" || true)
@@ -111,7 +111,7 @@ wait_for_rsync() {
wait_for_rsync wait_for_rsync
# ----------------------------- RUN ----------------------------- # RUN
stop_containers stop_containers
get_rsync_opts get_rsync_opts
+11 -21
View File
@@ -1,10 +1,9 @@
#!/bin/bash #!/bin/bash
# ----------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------
# ----------------- UNRAID OPS COMMON LIBRARY (FINAL STABLE FRAMEWORK v1) ----------------------- # ----------------- UNRAID OPS COMMON LIBRARY (STABLE FRAMEWORK v1) -----------------------
# ----------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------
# ----------------------------- ICONS ----------------------------- # ICONS Profiles
ICON_INFO="️" ICON_INFO="️"
ICON_WARN="⚠️" ICON_WARN="⚠️"
ICON_ERROR="❌" ICON_ERROR="❌"
@@ -15,8 +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] $*"; }
@@ -26,8 +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}
@@ -72,14 +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)"
@@ -105,8 +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)
@@ -116,8 +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() {
@@ -162,8 +155,7 @@ start_containers() {
done done
} }
# ----------------------------- RSYNC LIMITER (FIXED FINAL) ----------------------------- # RSYNC LIMITER (FIXED FINAL)
wait_for_rsync() { wait_for_rsync() {
: "${RETRY_COUNT:=5}" : "${RETRY_COUNT:=5}"
: "${MAX_RSYNC_PROCS:=2}" : "${MAX_RSYNC_PROCS:=2}"
@@ -191,8 +183,7 @@ 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]}"
@@ -201,8 +192,7 @@ get_rsync_opts() {
fi fi
} }
# ----------------------------- STATUS ----------------------------- # STATUS
show_status() { show_status() {
echo "===== STATUS =====" echo "===== STATUS ====="
echo "Local: $LOCAL_SERVER_NAME" echo "Local: $LOCAL_SERVER_NAME"