Platform adapter: rename System_Essentials, add Plugin/unraid/adapter.sh, wire call sites
- Rename unRAID_Essentials/ → System_Essentials/ (git detects as rename) - Add Plugin/unraid/adapter.sh: 13 platform_*() functions providing OS-agnostic API for storage health, service management, mover, user scripts, notifications, disk temps, and platform command validation - Update load_config.sh: detect PLATFORM (unraid/truenas/unknown), export SCRIPTS_DIR, auto-source Plugin/$PLATFORM/adapter.sh after common.sh - Wire all call sites: replace direct rc.d, pgrep/pkill, var.ini, dynamix.cfg, disks.ini, and validate_unraid_cmd calls with platform_*() functions across watchdogs, orchestrators, and System_Essentials scripts - Update all documentation: rename refs, update webgui escalation logic, add platform adapter section to Plugin README, update main README with portability vision and corrected self-healing stack description
This commit is contained in:
+21
-4
@@ -6,10 +6,12 @@
|
||||
# Every script sources this file instead of sourcing master.conf files directly.
|
||||
#
|
||||
# ── HOW IT WORKS ──────────────────────────────────────────────────────────────────────────────
|
||||
# 1. Sources master.conf (shared config — hostnames, thresholds, toggles, profiles, job lists)
|
||||
# 2. Auto-discovers and sources all host*.conf files in the same directory
|
||||
# 1. Detects OS platform → PLATFORM=unraid|truenas|unknown; exports SCRIPTS_DIR
|
||||
# 2. Sources master.conf (shared config — hostnames, thresholds, toggles, profiles, job lists)
|
||||
# 3. Auto-discovers and sources all host*.conf files in the same directory
|
||||
# Each host conf extends the shared profile arrays and adds host-specific credentials
|
||||
# 3. Sources common.sh (shared functions — detect_hosts, logging, notifications etc.)
|
||||
# 4. Sources common.sh (shared functions — detect_hosts, logging, notifications etc.)
|
||||
# 5. Sources Plugin/<platform>/adapter.sh (platform_*() functions for OS-specific ops)
|
||||
#
|
||||
# ── WHY THIS EXISTS ───────────────────────────────────────────────────────────────────────────
|
||||
# Without this loader every script had to explicitly source each conf file:
|
||||
@@ -53,6 +55,15 @@
|
||||
# Scripts call it from subdirectories using ../ — resolve to the actual root.
|
||||
LOAD_CONFIG_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# ━━━ Platform detection ━━━
|
||||
# PLATFORM drives the adapter layer — Plugin/<platform>/adapter.sh
|
||||
# Each platform adapter provides the same function API; scripts stay OS-agnostic.
|
||||
if [[ -f /etc/unraid-version ]]; then PLATFORM="unraid"
|
||||
elif [[ -f /etc/truenas ]]; then PLATFORM="truenas"
|
||||
else PLATFORM="unknown"
|
||||
fi
|
||||
export PLATFORM SCRIPTS_DIR="$LOAD_CONFIG_DIR"
|
||||
|
||||
# ━━━ Source shared config ━━━
|
||||
# master.conf must be sourced first — it declares the shared PROFILE_* arrays
|
||||
# that Host confs extend. Sourcing host confs before master.conf would fail.
|
||||
@@ -93,5 +104,11 @@
|
||||
fi
|
||||
source "$LOAD_CONFIG_DIR/common.sh"
|
||||
|
||||
# ━━━ Source platform adapter ━━━
|
||||
# Provides platform_*() functions used by common.sh and scripts.
|
||||
# Guard lets the ecosystem run before Plugin/<platform>/adapter.sh exists.
|
||||
_adapter="$LOAD_CONFIG_DIR/Plugin/$PLATFORM/adapter.sh"
|
||||
[[ -f "$_adapter" ]] && source "$_adapter"
|
||||
|
||||
# ━━━ Cleanup ━━━
|
||||
unset _conf _host_confs_loaded LOAD_CONFIG_DIR
|
||||
unset _conf _host_confs_loaded _adapter LOAD_CONFIG_DIR
|
||||
Reference in New Issue
Block a user