audit and clean master.conf, common.sh, and emby sync tools
master.conf: - reorder ORCHESTRATORS section by run frequency; add missing entries - remove heartbeat vars (watchdogs no longer run in continuous cycle) - remove dead REMOTE_DOCKER_RETRY_WAIT and display-only watchdog interval vars - move INTERMEDIATE_RSYNC_ENABLED into RSYNC two-tier block; reorder by frequency common.sh: - add missing info() and success() definitions — both were called throughout but never defined - update output tier description to list all 5 functions - fix double-icon in check_local_disk_temps() error/warn calls - fix smashed curl/ssh command lines in notify_emby_scan() and check_remote_docker_daemon() - update check_rsync_enabled() comment to include INTERMEDIATE, ordered by frequency emby_to_radarr_sync.sh / emby_to_sonarr_sync.sh: - wire up RADARR_EMBY_LIBRARIES / SONARR_EMBY_LIBRARIES; empty array now scans all libraries
This commit is contained in:
@@ -186,16 +186,20 @@ ICON_SUCCESS="✅"
|
||||
# ==============================================================================================
|
||||
# Standardised output functions used across all scripts.
|
||||
#
|
||||
# Two-tier model:
|
||||
# echo — always visible — summaries, status conclusions, section headers
|
||||
# warn() — always visible — state transitions, warnings, important events
|
||||
# error() — always visible — something broke
|
||||
# log() — only with --log flag — per-item detail, internal checks
|
||||
# Output tiers:
|
||||
# echo — always visible — summaries, status conclusions, section headers
|
||||
# info() — always visible — status confirmations, reachability, check pass
|
||||
# warn() — always visible — state transitions, warnings, important events
|
||||
# error() — always visible — something broke
|
||||
# success() — always visible — operation completed successfully
|
||||
# log() — only with --log flag — per-item detail, internal checks
|
||||
#
|
||||
# All output goes to stdout — callers can redirect as needed.
|
||||
|
||||
info() { echo "$ICON_INFO [INFO] $*"; }
|
||||
warn() { echo "$ICON_WARN [WARN] $*"; }
|
||||
error() { echo "$ICON_ERROR [ERROR] $*"; }
|
||||
success() { echo "$ICON_DONE [OK] $*"; }
|
||||
|
||||
log() {
|
||||
[[ "${ENABLE_LOGGING:-false}" == true ]] && echo "[LOG] $*"
|
||||
@@ -673,11 +677,12 @@ ping_internet() {
|
||||
# Tier 2: orchestrator-specific flag — fine-grained control per window
|
||||
#
|
||||
# Usage:
|
||||
# check_rsync_enabled "DAILY" ← checks RSYNC_ENABLED + DAILY_RSYNC_ENABLED
|
||||
# check_rsync_enabled "WEEKLY" ← checks RSYNC_ENABLED + WEEKLY_RSYNC_ENABLED
|
||||
# check_rsync_enabled "CRITICAL" ← checks RSYNC_ENABLED + CRITICAL_RSYNC_ENABLED
|
||||
# check_rsync_enabled "FALLBACK" ← checks RSYNC_ENABLED + FALLBACK_RSYNC_ENABLED
|
||||
# check_rsync_enabled ← checks RSYNC_ENABLED only (direct rsync.sh call)
|
||||
# check_rsync_enabled "CRITICAL" ← checks RSYNC_ENABLED + CRITICAL_RSYNC_ENABLED
|
||||
# check_rsync_enabled "INTERMEDIATE" ← checks RSYNC_ENABLED + INTERMEDIATE_RSYNC_ENABLED
|
||||
# check_rsync_enabled "DAILY" ← checks RSYNC_ENABLED + DAILY_RSYNC_ENABLED
|
||||
# check_rsync_enabled "WEEKLY" ← checks RSYNC_ENABLED + WEEKLY_RSYNC_ENABLED
|
||||
# check_rsync_enabled "FALLBACK" ← checks RSYNC_ENABLED + FALLBACK_RSYNC_ENABLED
|
||||
# check_rsync_enabled ← checks RSYNC_ENABLED only (direct rsync.sh call)
|
||||
#
|
||||
# Returns: 0 = enabled, proceed | 1 = disabled, skip cleanly
|
||||
|
||||
@@ -906,12 +911,12 @@ check_local_disk_temps() {
|
||||
|
||||
if [[ ${#crit_drives[@]} -gt 0 ]]; then
|
||||
TEMP_CHECK_RESULT="CRITICAL temps: ${crit_drives[*]}"
|
||||
error "$ICON_WARN Drive temp CRITICAL — aborting all remaining syncs: ${crit_drives[*]}"
|
||||
error "Drive temp CRITICAL — aborting all remaining syncs: ${crit_drives[*]}"
|
||||
notify "Rsync aborted on $(hostname) — drive temp CRITICAL: ${crit_drives[*]}" "Rsync Temp Check" "warning"
|
||||
return 2
|
||||
elif [[ ${#hot_drives[@]} -gt 0 ]]; then
|
||||
TEMP_CHECK_RESULT="HOT drives: ${hot_drives[*]}"
|
||||
warn "$ICON_WARN Drive temp WARNING — skipping this profile: ${hot_drives[*]}"
|
||||
warn "Drive temp WARNING — skipping this profile: ${hot_drives[*]}"
|
||||
notify "Rsync profile skipped on $(hostname) — drive temp WARNING: ${hot_drives[*]}" "Rsync Temp Check" "normal"
|
||||
return 1
|
||||
else
|
||||
@@ -1536,7 +1541,9 @@ notify_emby_scan() {
|
||||
|
||||
# Get all scheduled tasks
|
||||
local tasks_response
|
||||
tasks_response=$(curl -sf --max-time 15 -H "X-Api-Key: $EMBY_API_KEY" "${EMBY_URL}/ScheduledTasks" 2>/dev/null)
|
||||
tasks_response=$(curl -sf --max-time 15 \
|
||||
-H "X-Api-Key: $EMBY_API_KEY" \
|
||||
"${EMBY_URL}/ScheduledTasks" 2>/dev/null)
|
||||
|
||||
if [[ -z "$tasks_response" ]]; then
|
||||
warn "Could not reach Emby scheduled tasks API at $EMBY_URL — skipping scan"
|
||||
@@ -1545,11 +1552,17 @@ notify_emby_scan() {
|
||||
|
||||
# Find the "Clean Missing Files" task ID
|
||||
local task_id
|
||||
task_id=$(echo "$tasks_response" | grep -o '"Id":"[^"]*","Name":"[^"]*Clean Missing[^"]*"' | grep -o '"Id":"[^"]*"' | sed 's/"Id":"//;s/"//' | head -1)
|
||||
task_id=$(echo "$tasks_response" | \
|
||||
grep -o '"Id":"[^"]*","Name":"[^"]*Clean Missing[^"]*"' | \
|
||||
grep -o '"Id":"[^"]*"' | \
|
||||
sed 's/"Id":"//;s/"//' | head -1)
|
||||
|
||||
# Fallback — try "Scan Media Library" if Clean Missing not found
|
||||
if [[ -z "$task_id" ]]; then
|
||||
task_id=$(echo "$tasks_response" | grep -o '"Id":"[^"]*","Name":"[^"]*Scan Media Library[^"]*"' | grep -o '"Id":"[^"]*"' | sed 's/"Id":"//;s/"//' | head -1)
|
||||
task_id=$(echo "$tasks_response" | \
|
||||
grep -o '"Id":"[^"]*","Name":"[^"]*Scan Media Library[^"]*"' | \
|
||||
grep -o '"Id":"[^"]*"' | \
|
||||
sed 's/"Id":"//;s/"//' | head -1)
|
||||
[[ -n "$task_id" ]] && log "Clean Missing Files not found — using Scan Media Library"
|
||||
fi
|
||||
|
||||
@@ -1563,7 +1576,12 @@ notify_emby_scan() {
|
||||
|
||||
# Trigger the task
|
||||
local http_code
|
||||
http_code=$(curl -sf --max-time 15 -X POST -H "X-Api-Key: $EMBY_API_KEY" -w "%{http_code}" -o /dev/null "${EMBY_URL}/ScheduledTasks/Running/${task_id}" 2>/dev/null)
|
||||
http_code=$(curl -sf --max-time 15 \
|
||||
-X POST \
|
||||
-H "X-Api-Key: $EMBY_API_KEY" \
|
||||
-w "%{http_code}" \
|
||||
-o /dev/null \
|
||||
"${EMBY_URL}/ScheduledTasks/Running/${task_id}" 2>/dev/null)
|
||||
|
||||
if [[ "$http_code" == "204" ]] || [[ "$http_code" == "200" ]]; then
|
||||
warn "$ICON_EMBY Emby Clean Missing Files triggered — ghost entries will be removed"
|
||||
@@ -1687,7 +1705,8 @@ REMOTE_DOCKER_STRIKES=0
|
||||
check_remote_docker_daemon() {
|
||||
local timeout="${1:-10}"
|
||||
|
||||
if ssh -i "$SSH_KEY" -o ConnectTimeout="$timeout" root@"$REMOTE_SERVER" "timeout $timeout docker info" >/dev/null 2>&1; then
|
||||
if ssh -i "$SSH_KEY" -o ConnectTimeout="$timeout" root@"$REMOTE_SERVER" \
|
||||
"timeout $timeout docker info" >/dev/null 2>&1; then
|
||||
# Daemon healthy — clear strikes if we had issues
|
||||
if [[ "$REMOTE_DOCKER_STRIKES" -gt 0 ]]; then
|
||||
info "Remote Docker daemon on $REMOTE_SERVER_NAME recovered — clearing strikes"
|
||||
|
||||
Reference in New Issue
Block a user