ux update and code cleanup

This commit is contained in:
2026-04-06 23:19:04 +00:00
parent 8e4c588079
commit a5160c1af5
5 changed files with 205 additions and 66 deletions
+15 -14
View File
@@ -3,7 +3,7 @@
# ---------------------------- Master Variables for unRAID scripts -----------------------------
# ----------------------------------------------------------------------------------------------
# ----------------------- Host Configuration --------------------
# ━━━ Host Configuration ━━━
# List the Hostnames of both servers
HOST1="unRAID-Gmer4Lfe"
HOST2="unRAID-Jayred365"
@@ -12,16 +12,16 @@
HOST1_SSH_KEY="/root/.ssh/Gmer4Lfe-rsync-key"
HOST2_SSH_KEY="/root/.ssh/Jayred365-rsync-key"
# -------------------------- Logging ----------------------------
# ━━━ Logging ━━━
ENABLE_LOGGING=true # false = only echo user-facing messages
# ------------------ Git, Pull & Execute Script -----------------
# ━━━ Git, Pull & Execute Script ━━━
REPO_SSH="git@192.168.50.2:FailedProxy/Unraid_Scripts.git"
TARGET_DIR="/mnt/user/appdata/unraid_scripts"
GITEA_SSH_KEY="/root/.ssh/id_gitea_rsync"
SSH_PORT=221
# -------------------Rsync Script Defaults-----------------------
# ━━━ Rsync Script Defaults ━━━
# These are the fallback values used when no matching profile is found.
# Any share whose directory basename does not match a profile key below
# will use these globals for all rsync behaviour.
@@ -39,15 +39,15 @@
# Directories to exclude during transfer
EXCLUDE_DIRS=()
# Default global rsync options
DEFAULT_RSYNC_OPTS=(-av --info=progress2 --human-readable --bwlimit="$BW_LIMIT" --delete --inplace --no-whole-file)
DEFAULT_RSYNC_OPTS=(-av --info=progress2 --human-readable --bwlimit="$BW_LIMIT" --inplace --no-whole-file)
# ------------------- Remote Health Checks ----------------------
# ━━━ Remote Health Checks ━━━
# Abort if remote rootfs usage is at or above this percentage.
# Protects against rsync writing to rootfs when the remote array is down or drives are missing.
# Recommended: 75 — gives headroom before the server becomes unstable
ROOTFS_WARN=75
# ------------------- Daily Sync Shares -------------------------
# ━━━ Daily Sync Shares ━━━
# Shares synced once daily by Orchestrators/daily_sync.sh
# Add or remove paths here to manage what gets synced.
# These shares have no profile entry and fall through to DEFAULT_RSYNC_OPTS above.
@@ -55,19 +55,20 @@
/mnt/user/Anime_Movies-Old
/mnt/user/Anime_Shows-Old
/mnt/user/Anime_Shows
/mnt/user/Books
/mnt/user/appdata-Failover/Gmer4Lfe/
/mnt/user/Intros
/mnt/user/Kids_Movies
/mnt/user/Kids_Tv_Shows
/mnt/user/Movies
/mnt/user/Music-New
/mnt/user/Music_Videos
/mnt/user/Nextcloud
/mnt/user/stand-up_comedy
/mnt/user/Tv_Shows
/mnt/user/appdata-Failover/Gmer4Lfe/
)
# ------------------- unRAID essentail scripts ------------------
# ━━━ unRAID Essential Scripts ━━━
# unRAID reboot script user warning time (seconds)
REBOOT_SLEEP=300
# unRAID mover stop script timeout (seconds)
@@ -79,7 +80,7 @@
# php_fpm_max_children.sh max children value
PHP_MAX_CHILDREN=250
# --------------------- Profile System -------------------------
# ━━━ Profile System ━━━
# Profiles are matched by directory basename (lowercased).
# Example: /mnt/user/appdata-Failover/Arrs_Stack → profile key = arrs_stack
#
@@ -163,6 +164,6 @@ declare -A PROFILE_EXCLUDE_DIRS=(
[important-data]="logs *.tmp"
[emby]="logs *.tmp"
)
#-----------------------------------------------------------------------------------------------
#---------------------- End Of User Variables, Please adjust above as needed -------------------
#-----------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------
# ---------------------- End Of User Variables, Please adjust above as needed ------------------
# ----------------------------------------------------------------------------------------------
+12 -12
View File
@@ -1,6 +1,6 @@
#!/bin/bash
# -----------------------------------------------------------------------------------------------
# ----------------------------- Daily Sync Orchestrator (v1.5) ----------------------------------
# --------------------------------- Daily Sync Orchestrator ------------------------------------
# -----------------------------------------------------------------------------------------------
# Runs all bulk media shares sequentially. Scheduled via unRAID User Scripts plugin at 1am.
# Per-share rsync handled by rsync.sh — this script tracks pass/fail and total time only.
@@ -15,19 +15,19 @@ source "$SCRIPT_DIR/../common.sh"
RSYNC_SCRIPT="$SCRIPT_DIR/../Rsync/rsync.sh"
# -----------------------------------------------------------------------------------------------
# --- $ICON_GEAR Setup ---
# ━━━ $ICON_GEAR Setup ━━━
# -----------------------------------------------------------------------------------------------
echo ""
echo "--- $ICON_GEAR Setup ---"
echo "━━━ $ICON_GEAR Setup ━━━"
detect_hosts
resolve_remote_ip
# -----------------------------------------------------------------------------------------------
# --- $ICON_SHIELD Pre-flight Checks ---
# ━━━ $ICON_SHIELD Pre-flight Checks ━━━
# -----------------------------------------------------------------------------------------------
echo ""
echo "--- $ICON_SHIELD Pre-flight Checks ---"
echo "━━━ $ICON_SHIELD Pre-flight Checks ━━━"
# Single connectivity and rootfs check upfront — fail fast before attempting all shares
# Individual share and disk checks run per-share inside rsync.sh
@@ -44,10 +44,10 @@ TOTAL_START=$(date +%s)
SHARE_COUNT=${#DAILY_SYNC_SHARES[@]}
# -----------------------------------------------------------------------------------------------
# --- $ICON_SYNC Transfer ---
# ━━━ $ICON_SYNC Transfer ━━━
# -----------------------------------------------------------------------------------------------
echo ""
echo "--- $ICON_SYNC Daily Sync Starting — $(date '+%Y-%m-%d %H:%M:%S') ---"
echo "━━━ $ICON_SYNC Daily Sync Starting — $(date '+%Y-%m-%d %H:%M:%S') ━━━"
echo "$ICON_SUMMARY Shares: $SHARE_COUNT"
echo ""
@@ -58,7 +58,7 @@ for SHARE in "${DAILY_SYNC_SHARES[@]}"; do
SHARE_NAME=$(basename "$SHARE")
SHARE_START=$(date +%s)
echo "--- $ICON_SYNC Share $SHARE_INDEX of $SHARE_COUNT: $SHARE_NAME ---"
echo "━━━ $ICON_SYNC Share $SHARE_INDEX of $SHARE_COUNT: $SHARE_NAME ━━━"
if bash "$RSYNC_SCRIPT" "$SHARE"; then
SHARE_END=$(date +%s)
@@ -79,9 +79,9 @@ TOTAL_END=$(date +%s)
TOTAL_DURATION=$((TOTAL_END - TOTAL_START))
# -----------------------------------------------------------------------------------------------
# --- $ICON_SUMMARY Summary ---
# ━━━ $ICON_SUMMARY Summary ━━━
# -----------------------------------------------------------------------------------------------
echo "===== $ICON_SUMMARY DAILY SYNC SUMMARY ====="
echo "━━━━━ $ICON_SUMMARY DAILY SYNC SUMMARY ━━━━━"
echo "$ICON_TIME Started: $(date -d @$TOTAL_START '+%Y-%m-%d %H:%M:%S')"
echo "$ICON_TIME Finished: $(date -d @$TOTAL_END '+%Y-%m-%d %H:%M:%S')"
echo ""
@@ -91,14 +91,14 @@ for entry in "${SHARE_TIMES[@]}"; do
if printf '%s\n' "${FAIL[@]}" | grep -qx "$SHARE_NAME"; then
echo " $ICON_ERROR $SHARE_NAME$(format_duration $DURATION)"
else
echo " $ICON_DONE $SHARE_NAME$(format_duration $DURATION)"
echo " $ICON_DONE $SHARE_NAME$(format_duration $DURATION)"
fi
done
echo ""
echo " $ICON_SUCCESS Passed: ${#PASS[@]}/$SHARE_COUNT"
echo " $ICON_ERROR Failed: ${#FAIL[@]}/$SHARE_COUNT"
echo " $ICON_TIME Duration: $(format_duration $TOTAL_DURATION)"
echo "========================================="
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
[[ ${#FAIL[@]} -gt 0 ]] && exit 1
exit 0
+17 -17
View File
@@ -1,6 +1,6 @@
#!/bin/bash
# ----------------------------------------------------------------------------------------------
# -------------------------------- Rsync Core Script (v1.5) ------------------------------------
# --------------------------------- Rsync Core Script ------------------------------------------
# ----------------------------------------------------------------------------------------------
# ---------------- User Variables, Please adjust in Master.conf as needed ----------------------
# ----------------------------------------------------------------------------------------------
@@ -29,19 +29,19 @@ parse_args "${RAW_ARGS[@]}"
[[ -z "$DIRECTORY" ]] && error "No directory specified. Usage: rsync.sh <dir> [--dry-run] [--log]" && exit 1
# -----------------------------------------------------------------------------------------------
# --- $ICON_GEAR Setup ---
# ━━━ $ICON_GEAR Setup ━━━
# -----------------------------------------------------------------------------------------------
echo ""
echo "--- $ICON_GEAR Setup ---"
echo "━━━ $ICON_GEAR Setup ━━━"
detect_hosts
resolve_remote_ip
# -----------------------------------------------------------------------------------------------
# --- $ICON_SHIELD Pre-flight Checks ---
# ━━━ $ICON_SHIELD Pre-flight Checks ━━━
# -----------------------------------------------------------------------------------------------
echo ""
echo "--- $ICON_SHIELD Pre-flight Checks ---"
echo "━━━ $ICON_SHIELD Pre-flight Checks ━━━"
check_connectivity
check_remote_rootfs
@@ -70,20 +70,20 @@ read -r -a EXCLUDE_DIRS <<< "${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-
[[ "$SHOW_STATUS" == true ]] && show_status && exit 0
# -----------------------------------------------------------------------------------------------
# --- $ICON_STOP Containers ---
# ━━━ $ICON_STOP $ICON_CONTAINERS Containers ━━━
# -----------------------------------------------------------------------------------------------
echo ""
echo "--- $ICON_STOP Containers ---"
echo "━━━ $ICON_STOP $ICON_CONTAINERS Containers ━━━"
stop_containers
# -----------------------------------------------------------------------------------------------
# --- $ICON_SYNC Transfer ---
# ━━━ $ICON_SYNC Transfer ━━━
# -----------------------------------------------------------------------------------------------
echo ""
echo "--- $ICON_SYNC Transfer ---"
echo "$ICON_RUN Source: $DIRECTORY"
echo "$ICON_NET Remote: $REMOTE_SERVER:$DIRECTORY"
echo "━━━ $ICON_SYNC Transfer ━━━"
echo "$ICON_RUN Source: $DIRECTORY"
echo "$ICON_NET Remote: $REMOTE_SERVER:$DIRECTORY"
echo "$ICON_GEAR Profile: $PROFILE_NAME"
echo ""
@@ -117,29 +117,29 @@ for i in $(seq 1 "$RETRY_COUNT"); do
done
# -----------------------------------------------------------------------------------------------
# --- $ICON_START Containers ---
# ━━━ $ICON_START $ICON_CONTAINERS Containers ━━━
# -----------------------------------------------------------------------------------------------
echo ""
echo "--- $ICON_START Containers ---"
echo "━━━ $ICON_START $ICON_CONTAINERS Containers ━━━"
start_containers
END=$(date +%s)
# -----------------------------------------------------------------------------------------------
# --- $ICON_SUMMARY Summary ---
# ━━━ $ICON_SUMMARY Summary ━━━
# -----------------------------------------------------------------------------------------------
echo ""
echo "===== $ICON_SUMMARY SUMMARY ====="
echo "━━━━━ $ICON_SUMMARY SUMMARY ━━━━━"
echo "$ICON_RUN Directory: $DIRECTORY"
echo "$ICON_GEAR Profile: $PROFILE_NAME"
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
if [[ "$RSYNC_SUCCESS" == true ]]; then
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
else
echo "$ICON_ERROR Status: $ICON_ERROR FAILED after $RETRY_COUNT attempts"
echo "$ICON_ERROR Status: $ICON_ERROR FAILED after $RETRY_COUNT attempts"
fi
echo "========================="
echo "━━━━━━━━━━━━━━━━━━━━━━━"
[[ "$RSYNC_SUCCESS" == false ]] && exit 1
exit 0
+134
View File
@@ -0,0 +1,134 @@
#!/bin/bash
# -----------------------------------------------------------------------------------------------
# --------------------------------- Recreate Shares Script -------------------------------------
# -----------------------------------------------------------------------------------------------
# Reads all .cfg files from /boot/config/shares/ and creates the corresponding share
# directories on the correct disks based on shareInclude settings.
# Also drops a .recovery marker file in each share via /mnt/user/ so that an initial
# rsync push can run without --delete and self-clean on the second nightly run.
#
# Run this script directly on the secondary server after array is started.
# Usage: bash recreate_shares.sh
# -----------------------------------------------------------------------------------------------
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../Master.conf"
source "$SCRIPT_DIR/../common.sh"
SHARE_CFG_DIR="/boot/config/shares"
MARKER_FILE=".recovery"
CREATED=()
SKIPPED=()
FAILED=()
# -----------------------------------------------------------------------------------------------
# ━━━ $ICON_GEAR Setup ━━━
# -----------------------------------------------------------------------------------------------
echo ""
echo "━━━ $ICON_GEAR Setup ━━━"
if ! mountpoint -q /mnt/user; then
error "Array is not started — /mnt/user is not mounted"
info "Start the array in the unRAID UI before running this script"
exit 1
fi
success "Array is started"
# -----------------------------------------------------------------------------------------------
# ━━━ $ICON_DISK Recreating Shares ━━━
# -----------------------------------------------------------------------------------------------
echo ""
echo "━━━ $ICON_DISK Recreating Shares ━━━"
echo ""
for cfg in "$SHARE_CFG_DIR"/*.cfg; do
SHARE_NAME=$(basename "$cfg" .cfg)
INCLUDE=$(grep '^shareInclude=' "$cfg" | cut -d'"' -f2)
if [[ -z "$INCLUDE" ]]; then
warn "$SHARE_NAME — no shareInclude defined, skipping"
SKIPPED+=("$SHARE_NAME")
continue
fi
info "$ICON_DISK Processing $SHARE_NAME (disks: $INCLUDE)..."
SHARE_OK=true
IFS=',' read -ra DISKS <<< "$INCLUDE"
for disk in "${DISKS[@]}"; do
DISK_PATH="/mnt/${disk}/${SHARE_NAME}"
if [[ -d "$DISK_PATH" ]]; then
echo "$ICON_RUNNING $disk/$SHARE_NAME already exists, skipping"
else
if mkdir -p "$DISK_PATH"; then
echo "$ICON_STARTED Created $DISK_PATH"
else
error "Failed to create $DISK_PATH"
SHARE_OK=false
fi
fi
done
MARKER_PATH="/mnt/user/${SHARE_NAME}/${MARKER_FILE}"
if [[ "$SHARE_OK" == true ]]; then
if touch "$MARKER_PATH" 2>/dev/null; then
echo "$ICON_DONE Marker placed: $MARKER_PATH"
CREATED+=("$SHARE_NAME")
else
warn "Could not place marker in $SHARE_NAME — share may not be visible yet"
SKIPPED+=("$SHARE_NAME")
fi
else
FAILED+=("$SHARE_NAME")
fi
echo ""
done
# -----------------------------------------------------------------------------------------------
# ━━━ $ICON_SUMMARY Summary ━━━
# -----------------------------------------------------------------------------------------------
echo "━━━━━ $ICON_SUMMARY RECREATE SHARES SUMMARY ━━━━━"
echo ""
if [[ ${#CREATED[@]} -gt 0 ]]; then
echo " $ICON_DONE Created & marked:"
for s in "${CREATED[@]}"; do
echo " $ICON_STARTED $s"
done
echo ""
fi
if [[ ${#SKIPPED[@]} -gt 0 ]]; then
echo " $ICON_WARN Skipped:"
for s in "${SKIPPED[@]}"; do
echo " $ICON_NOT_RUNNING $s"
done
echo ""
fi
if [[ ${#FAILED[@]} -gt 0 ]]; then
echo " $ICON_ERROR Failed:"
for s in "${FAILED[@]}"; do
echo " $ICON_ERROR $s"
done
echo ""
fi
echo " $ICON_SUCCESS Created: ${#CREATED[@]}"
echo " $ICON_NOT_RUNNING Skipped: ${#SKIPPED[@]}"
echo " $ICON_ERROR Failed: ${#FAILED[@]}"
echo ""
echo "Next steps:"
echo " 1. $ICON_HEALTH Verify shares are visible in unRAID UI"
echo " 2. $ICON_GEAR Remove --delete from Master.conf rsync opts"
echo " 3. $ICON_RUN Run initial push — marker files self-clean on second nightly run"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
[[ ${#FAILED[@]} -gt 0 ]] && exit 1
exit 0
+27 -23
View File
@@ -1,6 +1,6 @@
#!/bin/bash
# -----------------------------------------------------------------------------------------------
# ----------------- UNRAID OPS COMMON LIBRARY (STABLE FRAMEWORK v1.5) ---------------------------
# ------------------------- UNRAID OPS COMMON LIBRARY (v1.6) ------------------------------------
# -----------------------------------------------------------------------------------------------
# Changelog:
# v1.0 — Initial stable framework
@@ -19,6 +19,10 @@
# v1.5 — Full icon set expanded — each operation and state has its own distinct icon
# All function output updated to use correct icon per context
# Icons grouped and commented by category for clarity
# v1.6 — ICON_CONTAINERS added — 📦 anchors all container sections for visual consistency
# ICON_NOT_RUNNING changed to ⭕ — distinct from ICON_STOPPED 🔴
# Section dividers updated from --- to ━━━ for cleaner log readability
# Summary passed/failed lines use ICON_SUCCESS and ICON_ERROR consistently
# -----------------------------------------------------------------------------------------------
# -----------------------------------------------------------------------------------------------
@@ -27,33 +31,34 @@
# -----------------------------------------------------------------------------------------------
# System / Host
ICON_HOST="🖥️" # host detection
ICON_NET="🌐" # network / IP resolution
ICON_PING="📡" # connectivity check
ICON_GEAR="⚙️" # setup section header / profile load
ICON_HOST="🖥️" # host detection
ICON_NET="🌐" # network / IP resolution
ICON_PING="📡" # connectivity check
ICON_GEAR="⚙️" # setup section header / profile load
# Health Checks
ICON_DISK="💾" # disk checks
ICON_HEALTH="🩺" # rootfs / share health checks
ICON_SHIELD="🛡️" # pre-flight section header
ICON_DISK="💾" # disk checks
ICON_HEALTH="🩺" # rootfs / share health checks
ICON_SHIELD="🛡️" # pre-flight section header
# Containers
ICON_STOP="" # stop command being issued
ICON_STOPPED="🔴" # container confirmed stopped
ICON_START="▶️" # start command being issued
ICON_STARTED="💚" # container confirmed started
ICON_RUNNING="🟢" # container already running when checked
ICON_NOT_RUNNING="🔴" # container already stopped when checked
ICON_CONTAINERS="📦" # container section anchor — paired with action icon for direction
ICON_STOP="" # stop command being issued
ICON_STOPPED="🔴" # container confirmed stopped
ICON_START="▶️" # start command being issued
ICON_STARTED="💚" # container confirmed started
ICON_RUNNING="🟢" # container already running when checked
ICON_NOT_RUNNING="⭕" # container already stopped when checked — distinct from ICON_STOPPED
# Transfer
ICON_SYNC="🔄" # transfer section header
ICON_RUN="🚀" # sync starting / rsync attempt
ICON_RETRY="🔁" # retry attempt
ICON_DONE="🏁" # transfer complete
ICON_SYNC="🔄" # transfer section header
ICON_RUN="🚀" # sync starting / rsync attempt
ICON_RETRY="🔁" # retry attempt
ICON_DONE="🏁" # transfer complete
# Summary
ICON_SUMMARY="📋" # summary section header
ICON_TIME="⏱️" # duration line
ICON_SUMMARY="📋" # summary section header
ICON_TIME="⏱️" # duration line
# Output
ICON_INFO="️"
@@ -299,7 +304,6 @@ check_remote_disks() {
info "$ICON_DISK Checking disks backing $share_name on $REMOTE_SERVER_NAME..."
# Find all /mnt/diskN paths that contain this share on the remote
DISK_PATHS=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \
"ls -d /mnt/disk*/$share_name 2>/dev/null" 2>/dev/null)
@@ -449,7 +453,7 @@ get_rsync_opts() {
# Useful for verifying profile resolution and variable state before a live run.
# -----------------------------------------------------------------------------------------------
show_status() {
echo "===== $ICON_SUMMARY STATUS ====="
echo "━━━━━ $ICON_SUMMARY STATUS ━━━━━"
echo "Local: $LOCAL_SERVER_NAME"
echo "Remote: $REMOTE_SERVER_NAME"
echo "IP: $REMOTE_SERVER"
@@ -459,5 +463,5 @@ show_status() {
echo "Containers: ${CRITICAL_CONTAINER_NAMES[*]}"
echo "Delayed: ${DELAYED_CONTAINERS[*]}"
echo "Excludes: ${EXCLUDE_DIRS[*]}"
echo "========================"
echo "━━━━━━━━━━━━━━━━━━━━━━━"
}