Platform-agnostic refactor: eliminate OS-specific hardcodes from core scripts

All bash scripts are now platform-neutral. Unraid-specific paths, commands,
and service checks moved to Plugin/unraid/adapter.sh. Core scripts call
platform_*() functions exclusively — no direct OS paths in runtime logic.

New adapter functions: platform_storage_path, platform_webui_install_path,
platform_scripts_dir_probe_cmd, platform_setup_db_path, platform_storage_healthy,
platform_is_service_enabled, platform_get_temp_thresholds, platform_disk_states_path,
platform_rebuild_container, platform_push_conf, platform_push_setup_state,
platform_get_templates_dir, platform_send_os_notification.

Partnership services stack (Emby/Jellyfin/Seerr/SeerrFin) added as third
onboarding stack alongside auth and arr stacks.
This commit is contained in:
Gmer4Lfe
2026-06-14 00:59:19 -04:00
parent fd1c4c7e3a
commit 27bfc21cb0
61 changed files with 411 additions and 444 deletions
+40 -43
View File
@@ -228,14 +228,11 @@ notify() {
log "$ICON_NOTIFY Sending notification: $subject$message"
# Guard is built in — scripts do NOT need to validate_unraid_cmd for the notify script.
if [[ "${NOTIFY_UNRAID:-false}" == true ]]; then
local notify_script="/usr/local/emhttp/plugins/dynamix/scripts/notify"
if [[ -x "$notify_script" ]]; then
"$notify_script" -s "$subject" -d "$message" -i "$severity" 2>/dev/null
log "$ICON_NOTIFY unRAID notification sent"
if platform_send_os_notification "$message" "$subject" "$severity"; then
log "$ICON_NOTIFY OS notification sent"
else
log "$ICON_NOTIFY unRAID notify script not found — skipping"
log "$ICON_NOTIFY OS notify not available — skipping"
fi
fi
@@ -586,6 +583,8 @@ detect_hosts() {
_alias_array "PARTNERSHIP_REPLACE_CONTAINERS"
_alias_array "PARTNERSHIP_ARR_STACK"
_alias_array "PARTNERSHIP_ARR_REPLACE_CONTAINERS"
_alias_array "PARTNERSHIP_SERVICES_STACK"
_alias_array "PARTNERSHIP_SERVICES_REPLACE_CONTAINERS"
_alias_array "RW_PAUSE_CONTAINERS"
_alias_array "RW_STOP_CONTAINERS"
@@ -727,34 +726,35 @@ check_rsync_enabled() {
}
# ==============================================================================================
# ── UNRAID SERVICE STATE ──────────────────────────────────────────────────────────────────────
# ── PLATFORM SERVICE STATE ────────────────────────────────────────────────────────────────────
# ==============================================================================================
# Reads Unraid config files to check whether Docker and VM Manager are enabled.
# Use these guards before any script that manages containers or VMs.
# Check whether Docker and VM Manager are enabled on this host.
# Delegates to platform_is_service_enabled() from the platform adapter.
is_docker_enabled() {
[[ "$(grep -oP '(?<=DOCKER_ENABLED=")[^"]+' /boot/config/docker.cfg 2>/dev/null)" == "yes" ]]
platform_is_service_enabled docker
}
is_vm_manager_enabled() {
[[ "$(grep -oP '(?<=SERVICE=")[^"]+' /boot/config/domain.cfg 2>/dev/null)" == "enable" ]]
platform_is_service_enabled libvirt
}
# ==============================================================================================
# ── LOCAL HEALTH CHECKS ───────────────────────────────────────────────────────────────────────
# ==============================================================================================
# Verifies local /mnt/user is mounted and has shares.
# Verifies local storage is mounted and has shares.
# Non-fatal — returns status for caller to decide.
# Used by fallback before starting remote containers locally.
check_local_array() {
log "Checking local array..."
if ! mountpoint -q /mnt/user 2>/dev/null; then
error "$ICON_DISK Local array is not started — /mnt/user is not mounted"
if ! platform_storage_healthy; then
error "$ICON_DISK Local array is not started — storage not mounted"
return 1
fi
local file_count
file_count=$(ls /mnt/user 2>/dev/null | wc -l)
local _storage_path file_count
_storage_path=$(platform_storage_path)
file_count=$(ls "$_storage_path" 2>/dev/null | wc -l)
if [[ "$file_count" -eq 0 ]]; then
error "$ICON_DISK Local array appears empty — shares may not be available"
return 1
@@ -767,14 +767,15 @@ check_local_array() {
# ── REMOTE HEALTH CHECKS ─────────────────────────────────────────────────────────────────────
# ==============================================================================================
# Verifies remote /mnt/user is mounted via SSH.
# Verifies remote storage is mounted via SSH.
# Non-fatal — returns status. Used before handback rsync.
# Syncing to remote with no array fills rootfs rapidly.
check_remote_array() {
log "Checking remote array on $REMOTE_SERVER_NAME..."
local result
local _spath result
_spath=$(platform_storage_path)
result=$(ssh -i "$SSH_KEY" -o ConnectTimeout=10 root@"$REMOTE_SERVER" \
"mountpoint -q /mnt/user && echo yes || echo no" 2>/dev/null)
"mountpoint -q '$_spath' && echo yes || echo no" 2>/dev/null)
if [[ "$result" != "yes" ]]; then
error "$ICON_DISK Remote array not started on $REMOTE_SERVER_NAME"
return 1
@@ -853,18 +854,11 @@ is_ssd() {
[[ "$(cat "/sys/block/$base/queue/rotational" 2>/dev/null)" == "0" ]]
}
# Reads disk temperature thresholds from unRAID's dynamix.cfg.
# Sets globals: UNRAID_DISK_HOT UNRAID_DISK_MAX UNRAID_SSD_HOT UNRAID_SSD_MAX
# Falls back to values in master.conf (SMART_TEMP_WARN/CRIT) if file not found.
# Falls back to master.conf values (SMART_TEMP_WARN/CRIT) if platform returns defaults.
get_unraid_temp_thresholds() {
local cfg="/boot/config/plugins/dynamix/dynamix.cfg"
if [[ -f "$cfg" ]]; then
UNRAID_DISK_HOT=$(grep '^hot=' "$cfg" 2>/dev/null | cut -d= -f2 | tr -d '"')
UNRAID_DISK_MAX=$(grep '^max=' "$cfg" 2>/dev/null | cut -d= -f2 | tr -d '"')
UNRAID_SSD_HOT=$(grep '^hotssd=' "$cfg" 2>/dev/null | cut -d= -f2 | tr -d '"')
UNRAID_SSD_MAX=$(grep '^maxssd=' "$cfg" 2>/dev/null | cut -d= -f2 | tr -d '"')
fi
# Fall back to master.conf values if dynamix.cfg not found or values empty
read -r UNRAID_DISK_HOT UNRAID_DISK_MAX UNRAID_SSD_HOT UNRAID_SSD_MAX \
<<< "$(platform_get_temp_thresholds)"
UNRAID_DISK_HOT="${UNRAID_DISK_HOT:-${SMART_TEMP_WARN:-45}}"
UNRAID_DISK_MAX="${UNRAID_DISK_MAX:-${SMART_TEMP_CRIT:-55}}"
UNRAID_SSD_HOT="${UNRAID_SSD_HOT:-60}"
@@ -884,10 +878,10 @@ get_unraid_temp_thresholds() {
check_local_disk_temps() {
get_unraid_temp_thresholds
local disks_ini="/var/local/emhttp/disks.ini"
if [[ ! -f "$disks_ini" ]]; then
warn "disks.ini not found — skipping temp check"
TEMP_CHECK_RESULT="temp check skipped (disks.ini not found)"
local disks_ini_content
if ! disks_ini_content=$(platform_get_disk_states); then
warn "disk state unavailable — skipping temp check"
TEMP_CHECK_RESULT="temp check skipped (disk state unavailable)"
return 0
fi
@@ -937,7 +931,7 @@ check_local_disk_temps() {
current_temp="${current_temp//[^0-9]/}"
current_temp="${current_temp:-0}"
fi
done < "$disks_ini"
done <<< "$disks_ini_content"
check_drive # process last drive
if [[ ${#crit_drives[@]} -gt 0 ]]; then
@@ -980,13 +974,14 @@ check_remote_disks() {
info "$ICON_DISK Checking disks backing $share_name on $REMOTE_SERVER_NAME..."
# Read remote disks.ini for fsType mapping
local disks_ini_content
# Read remote disk state for fsType mapping
local disks_ini_content _disk_states_path
_disk_states_path=$(platform_disk_states_path)
disks_ini_content=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \
"cat /var/local/emhttp/disks.ini 2>/dev/null" 2>/dev/null)
"cat '$_disk_states_path' 2>/dev/null" 2>/dev/null)
if [[ -z "$disks_ini_content" ]]; then
error "$ICON_DISK Cannot read disks.ini from $REMOTE_SERVER_NAME"
error "$ICON_DISK Cannot read disk state from $REMOTE_SERVER_NAME"
exit 1
fi
@@ -1004,11 +999,13 @@ check_remote_disks() {
grep -q . && echo \"\$pool\"
done | sort -u" 2>/dev/null)
# Tier 3 — shfs fallback via /mnt/user
# Tier 3 — storage root fallback
local _spath
_spath=$(platform_storage_path)
if [[ -z "$backing_disks" ]] && [[ -z "$zfs_pool_paths" ]]; then
local on_user
on_user=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \
"find /mnt/user -maxdepth 3 -name '$share_name' -type d 2>/dev/null | head -1" \
"find '$_spath' -maxdepth 3 -name '$share_name' -type d 2>/dev/null | head -1" \
2>/dev/null)
if [[ -n "$on_user" ]]; then
local actual_path
@@ -1020,12 +1017,12 @@ check_remote_disks() {
zfs_pool_paths="$pool_name"
info "$ICON_DISK $share_name found at $actual_path on $REMOTE_SERVER_NAME"
else
# Can't determine pool — verify shfs itself is mounted
# Can't determine pool — verify storage root itself is mounted
local shfs_ok
shfs_ok=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \
"mountpoint -q /mnt/user && echo yes || echo no" 2>/dev/null)
"mountpoint -q '$_spath' && echo yes || echo no" 2>/dev/null)
if [[ "$shfs_ok" == "yes" ]]; then
success "All disks backing $share_name are online ✅ (via shfs)"
success "All disks backing $share_name are online ✅ (via storage root)"
return 0
fi
fi