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
+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