feat: arr-native distributed media sync + config architecture fixes

Arr sync (new):
- Media/arr_sync.sh — full mesh bidirectional sync across all HOST* nodes
  - Lidarr (MusicBrainz), Sonarr (TVDB), Radarr (TMDB) all handled in one script
  - Remote API keys read live from config.xml via SSH — never stored in conf files
  - Shared blocklist (DATA_DIR/arr_sync_blocklist.tsv) merged from all nodes at runtime
  - Graceful skip if arr not configured locally or not reachable on a remote node
  - --blocklist-add / --blocklist-remove / --blocklist-list management flags
- daily_sync_maintenance.sh — arr sync runs as explicit phase before rsync
- partnership_onboard.sh — Step 3 bootstraps merged library on both sides at onboard
- master.conf — ARR_SYNC_* config block, DOCKER_APPDATA_BASE

Rsync / cleanup:
- DEFAULT_RSYNC_OPTS — removed --delete; arr_cleanup.sh owns orphan enforcement
- lidarr_cleanup.sh — removed HOST1-only guard; runs on any node with Lidarr configured

Config architecture:
- HOST1/HOST2 hostnames moved from master_host*.conf → master.conf (not credentials)
- Sparse checkout now works correctly: each server only needs its own host conf
- detect_hosts() still resolves MY_ID + REMOTE_ID via master.conf hostname values

Bug fix:
- common.sh line 493 — watchdog toggle eval had broken quoting; all SYS_WATCHDOG_CHECK_*
  globals were silently set to empty instead of their configured values

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gmer4Lfe
2026-05-09 09:53:40 -04:00
co-authored by Claude Sonnet 4.6
parent 009820e981
commit b65f572367
21 changed files with 1548 additions and 272 deletions
+62 -16
View File
@@ -20,12 +20,17 @@
# Step 2: partnership_manager.sh --onboard
# — verifies both servers, reconfigures auth WebUIs → owner IP,
# writes ACTIVE state, creates FolderView3 folder (if enabled)
# Step 3: arr_sync.sh — bidirectional library bootstrap: partner gets our full
# Lidarr/Sonarr/Radarr library, we get theirs. Both sides
# start tracking the merged library from day one.
# Non-fatal — partnership is valid even if arrs aren't live yet.
#
# ── USAGE ─────────────────────────────────────────────────────────────────────────────────────
# Initial_run/partnership_onboard.sh — full setup
# Initial_run/partnership_onboard.sh --dry-run — preview without changes
# Initial_run/partnership_onboard.sh --log — verbose output
# Initial_run/partnership_onboard.sh --skip-ssh — skip ssh_setup.sh (key already set up)
# Initial_run/partnership_onboard.sh — full setup
# Initial_run/partnership_onboard.sh --dry-run — preview without changes
# Initial_run/partnership_onboard.sh --log — verbose output
# Initial_run/partnership_onboard.sh --skip-ssh — skip ssh_setup.sh (key already set up)
# Initial_run/partnership_onboard.sh --skip-arr-sync — skip arr sync (arrs not live yet)
# ==============================================================================================
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -35,11 +40,13 @@ source "$SCRIPTS_ROOT/load_config.sh"
# ── Parse --skip-ssh before parse_args ────────────────────────────────────────────────────────
SKIP_SSH=false
SKIP_ARR_SYNC=false
FILTERED_ARGS=()
for arg in "$@"; do
case "$arg" in
--skip-ssh) SKIP_SSH=true ;;
*) FILTERED_ARGS+=("$arg") ;;
--skip-ssh) SKIP_SSH=true ;;
--skip-arr-sync) SKIP_ARR_SYNC=true ;;
*) FILTERED_ARGS+=("$arg") ;;
esac
done
@@ -74,7 +81,7 @@ EXTRA_FLAGS=()
# ━━━ Step 1: SSH Key Setup ━━━
# ==============================================================================================
echo ""
echo "━━━ Step 1/2 — SSH Key Setup ━━━"
echo "━━━ Step 1/3 — SSH Key Setup ━━━"
if [[ "$SKIP_SSH" == true ]]; then
warn "Skipping SSH setup (--skip-ssh)"
@@ -92,7 +99,7 @@ fi
# ━━━ Step 2: Partnership Onboard ━━━
# ==============================================================================================
echo ""
echo "━━━ Step 2/2 — Partnership Onboard ━━━"
echo "━━━ Step 2/3 — Partnership Onboard ━━━"
if bash "$SCRIPTS_ROOT/Partnership/partnership_manager.sh" --onboard "${EXTRA_FLAGS[@]}"; then
log "Partnership onboard complete ✅"
@@ -102,6 +109,37 @@ else
ONBOARD_OK=false
fi
# ==============================================================================================
# ━━━ Step 3: Arr Library Bootstrap ━━━
# ==============================================================================================
echo ""
echo "━━━ Step 3/3 — Arr Library Bootstrap ━━━"
ARR_SYNC_OK=true
if [[ "$ONBOARD_OK" == false ]]; then
warn "Skipping arr sync — onboard did not complete"
ARR_SYNC_OK=false
elif [[ "$SKIP_ARR_SYNC" == true ]]; then
warn "Skipping arr sync (--skip-arr-sync)"
ARR_SYNC_OK=false
else
ARR_SYNC_SCRIPT="$SCRIPTS_ROOT/Media/arr_sync.sh"
if [[ ! -f "$ARR_SYNC_SCRIPT" ]]; then
warn "arr_sync.sh not found — skipping library bootstrap"
warn "Run Media/arr_sync.sh manually once arrs are live"
ARR_SYNC_OK=false
else
log "Syncing arr libraries with $REMOTE_SERVER_NAME..."
if bash "$ARR_SYNC_SCRIPT" "${EXTRA_FLAGS[@]}"; then
log "Arr library bootstrap complete ✅"
else
warn "Arr sync completed with errors — partnership is still valid"
warn "Re-run Media/arr_sync.sh once all arr containers are live"
ARR_SYNC_OK=false
fi
fi
fi
# ==============================================================================================
# ━━━ Summary ━━━
# ==============================================================================================
@@ -113,20 +151,28 @@ echo "$ICON_NET Partner: $REMOTE_SERVER_NAME"
echo "$ICON_TIME Duration: $(format_duration $(( END - START )))"
echo ""
_ssh_status() { [[ "$SKIP_SSH" == true ]] && echo "skipped" || echo "✅"; }
_arr_status() {
if [[ "$SKIP_ARR_SYNC" == true ]]; then echo "skipped (--skip-arr-sync)"
elif [[ "$ONBOARD_OK" == false ]]; then echo "skipped (onboard failed)"
elif [[ "$ARR_SYNC_OK" == true ]]; then echo "✅"
else echo "⚠️ errors — re-run arr_sync.sh once arrs are live"
fi
}
echo " Step 1 — SSH key: $(_ssh_status)"
echo " Step 2 — Onboard: $( [[ "$ONBOARD_OK" == true ]] && echo "✅" || echo "❌" )"
echo " Step 3 — Arr bootstrap: $(_arr_status)"
echo ""
if [[ "$ONBOARD_OK" == true ]]; then
echo " Step 1 — SSH key: ✅"
echo " Step 2 — Onboard: ✅"
echo ""
if [[ "$DRY_RUN" == true ]]; then
warn "DRY RUN — no changes made"
else
warn "$ICON_DONE DONE — partnership established ✅"
warn "Next: verify with 'Partnership/partnership_manager.sh --status'"
log "$ICON_DONE DONE — partnership established ✅"
log "Next: verify with 'Partnership/partnership_manager.sh --status'"
fi
else
echo " Step 1 — SSH key: $( [[ "$SKIP_SSH" == true ]] && echo "skipped" || echo "✅" )"
echo " Step 2 — Onboard: ❌"
echo ""
error "Setup incomplete — resolve onboard errors above and re-run"
fi