Remove remaining OS-specific hardcodes from core scripts

OS version reads now go through platform_get_os_version() and
platform_os_version_probe_cmd() instead of grepping /etc/unraid-version directly.

STATE_DIR fallbacks to /boot/config removed — STATE_DIR is always set by
load_config.sh and the fallback encoded a platform-specific path.

Setup DB path references use platform_setup_db_path() instead of the
VARAVERK_SETUP_FILE/-/boot/config compound fallback.

DOCKER_APPDATA_BASE default removed from arr_sync.sh — the adapter sets it.
This commit is contained in:
Gmer4Lfe
2026-06-14 01:22:02 -04:00
parent 3c900ae5c1
commit ee5a07be1c
12 changed files with 65 additions and 42 deletions
+17 -17
View File
@@ -81,7 +81,7 @@
#
# Three new safety functions added:
# check_unraid_version_parity() — refuses remote ops on version mismatch
# reads /etc/unraid-version local and remote via SSH
# reads OS version via platform_get_os_version() / platform_os_version_probe_cmd()
# major mismatch → abort | minor mismatch → configurable warn/abort
# check_remote_docker_daemon() — verifies remote Docker daemon before
# issuing any remote container commands — strike system → skip/retry/exit
@@ -1741,7 +1741,7 @@ check_api() {
# remote operation. Version mismatches can mean changed APIs, commands, or behaviours
# that silently break remote container operations, rsync, or fallback logic.
#
# Reads /etc/unraid-version on both sides — format: version="7.2.3"
# Reads platform OS version on both sides via adapter.
#
# Mismatch behaviour (UNRAID_VERSION_MISMATCH_ACTION in master.conf):
# "warn" — log warning and continue (default for minor/patch differences)
@@ -1754,28 +1754,26 @@ check_unraid_version_parity() {
local local_version remote_version
# Read local version
if [[ ! -f /etc/unraid-version ]]; then
warn "Cannot read local /etc/unraid-version — skipping version parity check"
return 0
fi
local_version=$(grep -oP '(?<=version=")[^"]+' /etc/unraid-version 2>/dev/null)
local_version=$(platform_get_os_version 2>/dev/null)
if [[ -z "$local_version" ]]; then
warn "Cannot parse local unRAID version — skipping parity check"
warn "Cannot read local OS version — skipping version parity check"
return 0
fi
# Read remote version via SSH
local _probe_cmd
_probe_cmd=$(platform_os_version_probe_cmd)
remote_version=$(ssh -i "$SSH_KEY" -o ConnectTimeout=10 root@"$REMOTE_SERVER" \
"grep -oP '(?<=version=\")[^\"]+' /etc/unraid-version 2>/dev/null" 2>/dev/null)
"$_probe_cmd" 2>/dev/null)
if [[ -z "$remote_version" ]]; then
warn "Cannot read remote unRAID version from $REMOTE_SERVER_NAME — skipping parity check"
warn "Cannot read remote OS version from $REMOTE_SERVER_NAME — skipping parity check"
return 0
fi
log "Version parity: local=$local_version remote=$remote_version"
if [[ "$local_version" == "$remote_version" ]]; then
log "unRAID versions match: $local_version"
log "OS versions match: $local_version"
return 0
fi
@@ -1785,20 +1783,22 @@ check_unraid_version_parity() {
remote_major="${remote_version%%.*}"
if [[ "$local_major" != "$remote_major" ]]; then
error "unRAID MAJOR version mismatch — local: $local_version remote: $remote_version"
error "OS MAJOR version mismatch — local: $local_version remote: $remote_version"
error "Major version differences may break remote APIs, commands, and behaviours"
error "Update both servers to the same major version before running remote operations"
notify "unRAID major version mismatch on $(hostname) — local: $local_version remote: $remote_version — remote operations aborted" "Version Parity" "warning"
notify "OS major version mismatch on $(hostname) — local: $local_version remote: $remote_version — remote operations aborted" \
"Version Parity" "warning"
return 1
fi
# Minor/patch mismatch — action depends on config
local action="${UNRAID_VERSION_MISMATCH_ACTION:-warn}"
warn "unRAID version mismatch — local: $local_version remote: $remote_version"
warn "OS version mismatch — local: $local_version remote: $remote_version"
if [[ "$action" == "abort" ]]; then
error "UNRAID_VERSION_MISMATCH_ACTION=abort — refusing to continue"
notify "unRAID version mismatch on $(hostname) — local: $local_version remote: $remote_version — aborted" "Version Parity" "warning"
notify "OS version mismatch on $(hostname) — local: $local_version remote: $remote_version — aborted" \
"Version Parity" "warning"
return 1
fi
@@ -1906,14 +1906,14 @@ validate_unraid_cmd() {
show_status() {
local local_ver
local_ver=$(grep -oP '(?<=version=")[^"]+' /etc/unraid-version 2>/dev/null || echo "unknown")
local_ver=$(platform_get_os_version 2>/dev/null || echo "unknown")
echo "━━━━━ $ICON_SUMMARY STATUS ━━━━━"
echo "Local: $LOCAL_SERVER_NAME"
echo "Remote: $REMOTE_SERVER_NAME"
echo "IP: ${REMOTE_SERVER:-not resolved}"
echo "My ID: ${MY_ID:-not set}"
echo "Remote ID: ${REMOTE_ID:-not set}"
echo "unRAID ver: $local_ver"
echo "OS ver: $local_ver"
echo "Profile: ${PROFILE_NAME:-n/a}"
echo "DryRun: ${DRY_RUN:-false}"