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>
182 lines
8.2 KiB
Bash
Executable File
182 lines
8.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# ==============================================================================================
|
|
# ============================= Partnership Onboard Setup ======================================
|
|
# ==============================================================================================
|
|
# Orchestrates the full partnership setup sequence:
|
|
# 1. SSH key setup — generate keypair, install on remote, update conf
|
|
# 2. Partnership onboard — configure auth WebUIs, write state, FolderView3 folder
|
|
#
|
|
# Run this once to join a new partner server. Both servers run their own copy.
|
|
# After setup: critical_sync_maintenance.sh carries the relationship via --check.
|
|
#
|
|
# ── PRE-REQUISITES ────────────────────────────────────────────────────────────────────────────
|
|
# Both servers must be on the same Tailscale tailnet
|
|
# Remote server must have password auth enabled for root (SSH key install step)
|
|
# PARTNERSHIP_OWNER_HOST set correctly in master.conf (HOST1 = owner by default)
|
|
#
|
|
# ── WHAT THIS SCRIPT DOES ─────────────────────────────────────────────────────────────────────
|
|
# Step 1: ssh_setup.sh — generates {hostname}_rsync_automation keypair if missing,
|
|
# installs on remote via ssh-copy-id, updates master_host*.conf
|
|
# 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 --skip-arr-sync — skip arr sync (arrs not live yet)
|
|
# ==============================================================================================
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
SCRIPTS_ROOT="$SCRIPT_DIR/.."
|
|
|
|
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 ;;
|
|
--skip-arr-sync) SKIP_ARR_SYNC=true ;;
|
|
*) FILTERED_ARGS+=("$arg") ;;
|
|
esac
|
|
done
|
|
|
|
parse_args "${FILTERED_ARGS[@]}"
|
|
|
|
# ==============================================================================================
|
|
# ━━━ Setup ━━━
|
|
# ==============================================================================================
|
|
if [[ "$EUID" -ne 0 ]]; then
|
|
error "Must be run as root"
|
|
exit 1
|
|
fi
|
|
|
|
detect_hosts
|
|
|
|
START=$(date +%s)
|
|
|
|
echo ""
|
|
echo "━━━ $ICON_FALLBACK Partnership Onboard Setup — $MY_ID ($LOCAL_SERVER_NAME) — $(date '+%Y-%m-%d %H:%M:%S') ━━━"
|
|
echo ""
|
|
echo " This server: $MY_ID ($LOCAL_SERVER_NAME)"
|
|
echo " Partner: $REMOTE_ID ($REMOTE_SERVER_NAME)"
|
|
echo ""
|
|
|
|
[[ "$DRY_RUN" == true ]] && warn "DRY RUN — no permanent changes will be made"
|
|
|
|
EXTRA_FLAGS=()
|
|
[[ "$DRY_RUN" == true ]] && EXTRA_FLAGS+=("--dry-run")
|
|
[[ "$LOG_MODE" == true ]] && EXTRA_FLAGS+=("--log")
|
|
|
|
# ==============================================================================================
|
|
# ━━━ Step 1: SSH Key Setup ━━━
|
|
# ==============================================================================================
|
|
echo ""
|
|
echo "━━━ Step 1/3 — SSH Key Setup ━━━"
|
|
|
|
if [[ "$SKIP_SSH" == true ]]; then
|
|
warn "Skipping SSH setup (--skip-ssh)"
|
|
else
|
|
if bash "$SCRIPT_DIR/ssh_setup.sh" "${EXTRA_FLAGS[@]}"; then
|
|
log "SSH key setup complete ✅"
|
|
else
|
|
error "SSH key setup failed — aborting"
|
|
error "Fix SSH key issue then re-run, or use --skip-ssh if key is already set up"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# ==============================================================================================
|
|
# ━━━ Step 2: Partnership Onboard ━━━
|
|
# ==============================================================================================
|
|
echo ""
|
|
echo "━━━ Step 2/3 — Partnership Onboard ━━━"
|
|
|
|
if bash "$SCRIPTS_ROOT/Partnership/partnership_manager.sh" --onboard "${EXTRA_FLAGS[@]}"; then
|
|
log "Partnership onboard complete ✅"
|
|
ONBOARD_OK=true
|
|
else
|
|
error "Partnership onboard failed"
|
|
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 ━━━
|
|
# ==============================================================================================
|
|
END=$(date +%s)
|
|
echo ""
|
|
echo "━━━━━ $ICON_SUMMARY PARTNERSHIP SETUP SUMMARY ━━━━━"
|
|
echo "$ICON_HOST Identity: $MY_ID ($LOCAL_SERVER_NAME)"
|
|
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
|
|
if [[ "$DRY_RUN" == true ]]; then
|
|
warn "DRY RUN — no changes made"
|
|
else
|
|
log "$ICON_DONE DONE — partnership established ✅"
|
|
log "Next: verify with 'Partnership/partnership_manager.sh --status'"
|
|
fi
|
|
else
|
|
error "Setup incomplete — resolve onboard errors above and re-run"
|
|
fi
|
|
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━"
|
|
[[ "$ONBOARD_OK" == false ]] && exit 1
|
|
exit 0
|