ux update and code cleanup
This commit is contained in:
+15
-14
@@ -3,7 +3,7 @@
|
|||||||
# ---------------------------- Master Variables for unRAID scripts -----------------------------
|
# ---------------------------- Master Variables for unRAID scripts -----------------------------
|
||||||
# ----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# ----------------------- Host Configuration --------------------
|
# ━━━ Host Configuration ━━━
|
||||||
# List the Hostnames of both servers
|
# List the Hostnames of both servers
|
||||||
HOST1="unRAID-Gmer4Lfe"
|
HOST1="unRAID-Gmer4Lfe"
|
||||||
HOST2="unRAID-Jayred365"
|
HOST2="unRAID-Jayred365"
|
||||||
@@ -12,16 +12,16 @@
|
|||||||
HOST1_SSH_KEY="/root/.ssh/Gmer4Lfe-rsync-key"
|
HOST1_SSH_KEY="/root/.ssh/Gmer4Lfe-rsync-key"
|
||||||
HOST2_SSH_KEY="/root/.ssh/Jayred365-rsync-key"
|
HOST2_SSH_KEY="/root/.ssh/Jayred365-rsync-key"
|
||||||
|
|
||||||
# -------------------------- Logging ----------------------------
|
# ━━━ Logging ━━━
|
||||||
ENABLE_LOGGING=true # false = only echo user-facing messages
|
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"
|
REPO_SSH="git@192.168.50.2:FailedProxy/Unraid_Scripts.git"
|
||||||
TARGET_DIR="/mnt/user/appdata/unraid_scripts"
|
TARGET_DIR="/mnt/user/appdata/unraid_scripts"
|
||||||
GITEA_SSH_KEY="/root/.ssh/id_gitea_rsync"
|
GITEA_SSH_KEY="/root/.ssh/id_gitea_rsync"
|
||||||
SSH_PORT=221
|
SSH_PORT=221
|
||||||
|
|
||||||
# -------------------Rsync Script Defaults-----------------------
|
# ━━━ Rsync Script Defaults ━━━
|
||||||
# These are the fallback values used when no matching profile is found.
|
# These are the fallback values used when no matching profile is found.
|
||||||
# Any share whose directory basename does not match a profile key below
|
# Any share whose directory basename does not match a profile key below
|
||||||
# will use these globals for all rsync behaviour.
|
# will use these globals for all rsync behaviour.
|
||||||
@@ -39,15 +39,15 @@
|
|||||||
# Directories to exclude during transfer
|
# Directories to exclude during transfer
|
||||||
EXCLUDE_DIRS=()
|
EXCLUDE_DIRS=()
|
||||||
# Default global rsync options
|
# 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.
|
# 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.
|
# 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
|
# Recommended: 75 — gives headroom before the server becomes unstable
|
||||||
ROOTFS_WARN=75
|
ROOTFS_WARN=75
|
||||||
|
|
||||||
# ------------------- Daily Sync Shares -------------------------
|
# ━━━ Daily Sync Shares ━━━
|
||||||
# Shares synced once daily by Orchestrators/daily_sync.sh
|
# Shares synced once daily by Orchestrators/daily_sync.sh
|
||||||
# Add or remove paths here to manage what gets synced.
|
# Add or remove paths here to manage what gets synced.
|
||||||
# These shares have no profile entry and fall through to DEFAULT_RSYNC_OPTS above.
|
# 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_Movies-Old
|
||||||
/mnt/user/Anime_Shows-Old
|
/mnt/user/Anime_Shows-Old
|
||||||
/mnt/user/Anime_Shows
|
/mnt/user/Anime_Shows
|
||||||
/mnt/user/Books
|
/mnt/user/appdata-Failover/Gmer4Lfe/
|
||||||
/mnt/user/Intros
|
/mnt/user/Intros
|
||||||
/mnt/user/Kids_Movies
|
/mnt/user/Kids_Movies
|
||||||
/mnt/user/Kids_Tv_Shows
|
/mnt/user/Kids_Tv_Shows
|
||||||
/mnt/user/Movies
|
/mnt/user/Movies
|
||||||
|
/mnt/user/Music-New
|
||||||
/mnt/user/Music_Videos
|
/mnt/user/Music_Videos
|
||||||
/mnt/user/Nextcloud
|
/mnt/user/Nextcloud
|
||||||
/mnt/user/stand-up_comedy
|
/mnt/user/stand-up_comedy
|
||||||
/mnt/user/Tv_Shows
|
/mnt/user/Tv_Shows
|
||||||
/mnt/user/appdata-Failover/Gmer4Lfe/
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# ------------------- unRAID essentail scripts ------------------
|
# ━━━ unRAID Essential Scripts ━━━
|
||||||
# unRAID reboot script user warning time (seconds)
|
# unRAID reboot script user warning time (seconds)
|
||||||
REBOOT_SLEEP=300
|
REBOOT_SLEEP=300
|
||||||
# unRAID mover stop script timeout (seconds)
|
# unRAID mover stop script timeout (seconds)
|
||||||
@@ -79,7 +80,7 @@
|
|||||||
# php_fpm_max_children.sh max children value
|
# php_fpm_max_children.sh max children value
|
||||||
PHP_MAX_CHILDREN=250
|
PHP_MAX_CHILDREN=250
|
||||||
|
|
||||||
# --------------------- Profile System -------------------------
|
# ━━━ Profile System ━━━
|
||||||
# Profiles are matched by directory basename (lowercased).
|
# Profiles are matched by directory basename (lowercased).
|
||||||
# Example: /mnt/user/appdata-Failover/Arrs_Stack → profile key = arrs_stack
|
# Example: /mnt/user/appdata-Failover/Arrs_Stack → profile key = arrs_stack
|
||||||
#
|
#
|
||||||
@@ -163,6 +164,6 @@ declare -A PROFILE_EXCLUDE_DIRS=(
|
|||||||
[important-data]="logs *.tmp"
|
[important-data]="logs *.tmp"
|
||||||
[emby]="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
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ----------------------------- Daily Sync Orchestrator (v1.5) ----------------------------------
|
# --------------------------------- Daily Sync Orchestrator ------------------------------------
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# Runs all bulk media shares sequentially. Scheduled via unRAID User Scripts plugin at 1am.
|
# 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.
|
# 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"
|
RSYNC_SCRIPT="$SCRIPT_DIR/../Rsync/rsync.sh"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# --- $ICON_GEAR Setup ---
|
# ━━━ $ICON_GEAR Setup ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- $ICON_GEAR Setup ---"
|
echo "━━━ $ICON_GEAR Setup ━━━"
|
||||||
|
|
||||||
detect_hosts
|
detect_hosts
|
||||||
resolve_remote_ip
|
resolve_remote_ip
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# --- $ICON_SHIELD Pre-flight Checks ---
|
# ━━━ $ICON_SHIELD Pre-flight Checks ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
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
|
# Single connectivity and rootfs check upfront — fail fast before attempting all shares
|
||||||
# Individual share and disk checks run per-share inside rsync.sh
|
# Individual share and disk checks run per-share inside rsync.sh
|
||||||
@@ -44,10 +44,10 @@ TOTAL_START=$(date +%s)
|
|||||||
SHARE_COUNT=${#DAILY_SYNC_SHARES[@]}
|
SHARE_COUNT=${#DAILY_SYNC_SHARES[@]}
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# --- $ICON_SYNC Transfer ---
|
# ━━━ $ICON_SYNC Transfer ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
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 "$ICON_SUMMARY Shares: $SHARE_COUNT"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ for SHARE in "${DAILY_SYNC_SHARES[@]}"; do
|
|||||||
SHARE_NAME=$(basename "$SHARE")
|
SHARE_NAME=$(basename "$SHARE")
|
||||||
SHARE_START=$(date +%s)
|
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
|
if bash "$RSYNC_SCRIPT" "$SHARE"; then
|
||||||
SHARE_END=$(date +%s)
|
SHARE_END=$(date +%s)
|
||||||
@@ -79,9 +79,9 @@ TOTAL_END=$(date +%s)
|
|||||||
TOTAL_DURATION=$((TOTAL_END - TOTAL_START))
|
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 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 "$ICON_TIME Finished: $(date -d @$TOTAL_END '+%Y-%m-%d %H:%M:%S')"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -91,14 +91,14 @@ for entry in "${SHARE_TIMES[@]}"; do
|
|||||||
if printf '%s\n' "${FAIL[@]}" | grep -qx "$SHARE_NAME"; then
|
if printf '%s\n' "${FAIL[@]}" | grep -qx "$SHARE_NAME"; then
|
||||||
echo " $ICON_ERROR $SHARE_NAME — $(format_duration $DURATION)"
|
echo " $ICON_ERROR $SHARE_NAME — $(format_duration $DURATION)"
|
||||||
else
|
else
|
||||||
echo " $ICON_DONE $SHARE_NAME — $(format_duration $DURATION)"
|
echo " $ICON_DONE $SHARE_NAME — $(format_duration $DURATION)"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo ""
|
echo ""
|
||||||
echo " $ICON_SUCCESS Passed: ${#PASS[@]}/$SHARE_COUNT"
|
echo " $ICON_SUCCESS Passed: ${#PASS[@]}/$SHARE_COUNT"
|
||||||
echo " $ICON_ERROR Failed: ${#FAIL[@]}/$SHARE_COUNT"
|
echo " $ICON_ERROR Failed: ${#FAIL[@]}/$SHARE_COUNT"
|
||||||
echo " $ICON_TIME Duration: $(format_duration $TOTAL_DURATION)"
|
echo " $ICON_TIME Duration: $(format_duration $TOTAL_DURATION)"
|
||||||
echo "========================================="
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
|
|
||||||
[[ ${#FAIL[@]} -gt 0 ]] && exit 1
|
[[ ${#FAIL[@]} -gt 0 ]] && exit 1
|
||||||
exit 0
|
exit 0
|
||||||
+17
-17
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# ----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
# -------------------------------- Rsync Core Script (v1.5) ------------------------------------
|
# --------------------------------- Rsync Core Script ------------------------------------------
|
||||||
# ----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
# ---------------- User Variables, Please adjust in Master.conf as needed ----------------------
|
# ---------------- 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
|
[[ -z "$DIRECTORY" ]] && error "No directory specified. Usage: rsync.sh <dir> [--dry-run] [--log]" && exit 1
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# --- $ICON_GEAR Setup ---
|
# ━━━ $ICON_GEAR Setup ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- $ICON_GEAR Setup ---"
|
echo "━━━ $ICON_GEAR Setup ━━━"
|
||||||
|
|
||||||
detect_hosts
|
detect_hosts
|
||||||
resolve_remote_ip
|
resolve_remote_ip
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# --- $ICON_SHIELD Pre-flight Checks ---
|
# ━━━ $ICON_SHIELD Pre-flight Checks ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- $ICON_SHIELD Pre-flight Checks ---"
|
echo "━━━ $ICON_SHIELD Pre-flight Checks ━━━"
|
||||||
|
|
||||||
check_connectivity
|
check_connectivity
|
||||||
check_remote_rootfs
|
check_remote_rootfs
|
||||||
@@ -70,20 +70,20 @@ read -r -a EXCLUDE_DIRS <<< "${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-
|
|||||||
[[ "$SHOW_STATUS" == true ]] && show_status && exit 0
|
[[ "$SHOW_STATUS" == true ]] && show_status && exit 0
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# --- $ICON_STOP Containers ---
|
# ━━━ $ICON_STOP $ICON_CONTAINERS Containers ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- $ICON_STOP Containers ---"
|
echo "━━━ $ICON_STOP $ICON_CONTAINERS Containers ━━━"
|
||||||
|
|
||||||
stop_containers
|
stop_containers
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# --- $ICON_SYNC Transfer ---
|
# ━━━ $ICON_SYNC Transfer ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- $ICON_SYNC Transfer ---"
|
echo "━━━ $ICON_SYNC Transfer ━━━"
|
||||||
echo "$ICON_RUN Source: $DIRECTORY"
|
echo "$ICON_RUN Source: $DIRECTORY"
|
||||||
echo "$ICON_NET Remote: $REMOTE_SERVER:$DIRECTORY"
|
echo "$ICON_NET Remote: $REMOTE_SERVER:$DIRECTORY"
|
||||||
echo "$ICON_GEAR Profile: $PROFILE_NAME"
|
echo "$ICON_GEAR Profile: $PROFILE_NAME"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
@@ -117,29 +117,29 @@ for i in $(seq 1 "$RETRY_COUNT"); do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# --- $ICON_START Containers ---
|
# ━━━ $ICON_START $ICON_CONTAINERS Containers ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- $ICON_START Containers ---"
|
echo "━━━ $ICON_START $ICON_CONTAINERS Containers ━━━"
|
||||||
|
|
||||||
start_containers
|
start_containers
|
||||||
|
|
||||||
END=$(date +%s)
|
END=$(date +%s)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# --- $ICON_SUMMARY Summary ---
|
# ━━━ $ICON_SUMMARY Summary ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "===== $ICON_SUMMARY SUMMARY ====="
|
echo "━━━━━ $ICON_SUMMARY SUMMARY ━━━━━"
|
||||||
echo "$ICON_RUN Directory: $DIRECTORY"
|
echo "$ICON_RUN Directory: $DIRECTORY"
|
||||||
echo "$ICON_GEAR Profile: $PROFILE_NAME"
|
echo "$ICON_GEAR Profile: $PROFILE_NAME"
|
||||||
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
||||||
if [[ "$RSYNC_SUCCESS" == true ]]; then
|
if [[ "$RSYNC_SUCCESS" == true ]]; then
|
||||||
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
|
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
|
||||||
else
|
else
|
||||||
echo "$ICON_ERROR Status: $ICON_ERROR FAILED after $RETRY_COUNT attempts"
|
echo "$ICON_ERROR Status: $ICON_ERROR FAILED after $RETRY_COUNT attempts"
|
||||||
fi
|
fi
|
||||||
echo "========================="
|
echo "━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
|
|
||||||
[[ "$RSYNC_SUCCESS" == false ]] && exit 1
|
[[ "$RSYNC_SUCCESS" == false ]] && exit 1
|
||||||
exit 0
|
exit 0
|
||||||
@@ -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
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ----------------- UNRAID OPS COMMON LIBRARY (STABLE FRAMEWORK v1.5) ---------------------------
|
# ------------------------- UNRAID OPS COMMON LIBRARY (v1.6) ------------------------------------
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# Changelog:
|
# Changelog:
|
||||||
# v1.0 — Initial stable framework
|
# v1.0 — Initial stable framework
|
||||||
@@ -19,6 +19,10 @@
|
|||||||
# v1.5 — Full icon set expanded — each operation and state has its own distinct icon
|
# 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
|
# All function output updated to use correct icon per context
|
||||||
# Icons grouped and commented by category for clarity
|
# 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
|
# System / Host
|
||||||
ICON_HOST="🖥️" # host detection
|
ICON_HOST="🖥️" # host detection
|
||||||
ICON_NET="🌐" # network / IP resolution
|
ICON_NET="🌐" # network / IP resolution
|
||||||
ICON_PING="📡" # connectivity check
|
ICON_PING="📡" # connectivity check
|
||||||
ICON_GEAR="⚙️" # setup section header / profile load
|
ICON_GEAR="⚙️" # setup section header / profile load
|
||||||
|
|
||||||
# Health Checks
|
# Health Checks
|
||||||
ICON_DISK="💾" # disk checks
|
ICON_DISK="💾" # disk checks
|
||||||
ICON_HEALTH="🩺" # rootfs / share health checks
|
ICON_HEALTH="🩺" # rootfs / share health checks
|
||||||
ICON_SHIELD="🛡️" # pre-flight section header
|
ICON_SHIELD="🛡️" # pre-flight section header
|
||||||
|
|
||||||
# Containers
|
# Containers
|
||||||
ICON_STOP="⛔" # stop command being issued
|
ICON_CONTAINERS="📦" # container section anchor — paired with action icon for direction
|
||||||
ICON_STOPPED="🔴" # container confirmed stopped
|
ICON_STOP="⛔" # stop command being issued
|
||||||
ICON_START="▶️" # start command being issued
|
ICON_STOPPED="🔴" # container confirmed stopped
|
||||||
ICON_STARTED="💚" # container confirmed started
|
ICON_START="▶️" # start command being issued
|
||||||
ICON_RUNNING="🟢" # container already running when checked
|
ICON_STARTED="💚" # container confirmed started
|
||||||
ICON_NOT_RUNNING="🔴" # container already stopped when checked
|
ICON_RUNNING="🟢" # container already running when checked
|
||||||
|
ICON_NOT_RUNNING="⭕" # container already stopped when checked — distinct from ICON_STOPPED
|
||||||
|
|
||||||
# Transfer
|
# Transfer
|
||||||
ICON_SYNC="🔄" # transfer section header
|
ICON_SYNC="🔄" # transfer section header
|
||||||
ICON_RUN="🚀" # sync starting / rsync attempt
|
ICON_RUN="🚀" # sync starting / rsync attempt
|
||||||
ICON_RETRY="🔁" # retry attempt
|
ICON_RETRY="🔁" # retry attempt
|
||||||
ICON_DONE="🏁" # transfer complete
|
ICON_DONE="🏁" # transfer complete
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
ICON_SUMMARY="📋" # summary section header
|
ICON_SUMMARY="📋" # summary section header
|
||||||
ICON_TIME="⏱️" # duration line
|
ICON_TIME="⏱️" # duration line
|
||||||
|
|
||||||
# Output
|
# Output
|
||||||
ICON_INFO="ℹ️"
|
ICON_INFO="ℹ️"
|
||||||
@@ -299,7 +304,6 @@ check_remote_disks() {
|
|||||||
|
|
||||||
info "$ICON_DISK Checking disks backing $share_name on $REMOTE_SERVER_NAME..."
|
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" \
|
DISK_PATHS=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \
|
||||||
"ls -d /mnt/disk*/$share_name 2>/dev/null" 2>/dev/null)
|
"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.
|
# Useful for verifying profile resolution and variable state before a live run.
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
show_status() {
|
show_status() {
|
||||||
echo "===== $ICON_SUMMARY STATUS ====="
|
echo "━━━━━ $ICON_SUMMARY STATUS ━━━━━"
|
||||||
echo "Local: $LOCAL_SERVER_NAME"
|
echo "Local: $LOCAL_SERVER_NAME"
|
||||||
echo "Remote: $REMOTE_SERVER_NAME"
|
echo "Remote: $REMOTE_SERVER_NAME"
|
||||||
echo "IP: $REMOTE_SERVER"
|
echo "IP: $REMOTE_SERVER"
|
||||||
@@ -459,5 +463,5 @@ show_status() {
|
|||||||
echo "Containers: ${CRITICAL_CONTAINER_NAMES[*]}"
|
echo "Containers: ${CRITICAL_CONTAINER_NAMES[*]}"
|
||||||
echo "Delayed: ${DELAYED_CONTAINERS[*]}"
|
echo "Delayed: ${DELAYED_CONTAINERS[*]}"
|
||||||
echo "Excludes: ${EXCLUDE_DIRS[*]}"
|
echo "Excludes: ${EXCLUDE_DIRS[*]}"
|
||||||
echo "========================"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user