From 35e59d2510c3d686b142e2f9b873c72db13551fe Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Sun, 16 Aug 2026 19:40:49 -0400 Subject: [PATCH] Let the plugin read partner vars from the same RAM cache bash reads, so PHP and bash cannot disagree about a partner --- Arrs_Stack/arr_sync.sh | 2 +- Deployment/conf_populate.sh | 2 +- Orchestrators/intermediate_sync_maintenance.sh | 2 +- Plugin/unraid/include/common.php | 13 ++++++++++++- System_Essentials/conf_cache_restore.sh | 2 +- System_Essentials/conf_cache_save.sh | 2 +- System_Essentials/conf_sync.sh | 14 +++++++------- load_config.sh | 2 +- 8 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Arrs_Stack/arr_sync.sh b/Arrs_Stack/arr_sync.sh index 5e6a6eb..6a703a2 100755 --- a/Arrs_Stack/arr_sync.sh +++ b/Arrs_Stack/arr_sync.sh @@ -44,7 +44,7 @@ # ============================================================================================== # # Remote API Access — Cache-First, SSH Fallback -# If conf_sync.sh has populated /tmp/.cache/vv/d/ and +# If conf_sync.sh has populated /tmp/varaverk/conf/ and # load_config.sh has sourced it, HOST*__API_KEY vars are available # in the environment. Remote functions use them to call the arr API # directly over Tailscale (no SSH, no remote shell). If the cached key diff --git a/Deployment/conf_populate.sh b/Deployment/conf_populate.sh index 3e2bf77..25ee327 100755 --- a/Deployment/conf_populate.sh +++ b/Deployment/conf_populate.sh @@ -10,7 +10,7 @@ # EMPTY fields, never overwrites existing values unless --overwrite is passed. # # After populating, pushes the updated conf to all partners via conf_sync.sh -# so they have the fresh keys in their /tmp/.cache/vv/d/ cache immediately. +# so they have the fresh keys in their /tmp/varaverk/conf/ cache immediately. # # ============================================================================================== # AUTO-DETECTED FIELDS diff --git a/Orchestrators/intermediate_sync_maintenance.sh b/Orchestrators/intermediate_sync_maintenance.sh index 0575412..6990e65 100755 --- a/Orchestrators/intermediate_sync_maintenance.sh +++ b/Orchestrators/intermediate_sync_maintenance.sh @@ -12,7 +12,7 @@ # OPERATIONAL MODEL # ============================================================================================== # -# 1. conf_sync.sh --pull-only — refresh partner conf cache in RAM (/tmp/.cache/vv/d/) +# 1. conf_sync.sh --pull-only — refresh partner conf cache in RAM (/tmp/varaverk/conf/) # 2. arr_sync.sh — sync Lidarr/Sonarr/Radarr libraries across all nodes # 3. Rsync window (optional) — INTERMEDIATE_SYNC_SHARES, if any configured # 4. INTERMEDIATE_MAINTENANCE_SCRIPTS — artwork fetch and any future 4-hour jobs diff --git a/Plugin/unraid/include/common.php b/Plugin/unraid/include/common.php index 96293c8..9d93afc 100644 --- a/Plugin/unraid/include/common.php +++ b/Plugin/unraid/include/common.php @@ -729,8 +729,19 @@ function vv_disk_thresholds(): array { // Results are cached in /tmp for 30 seconds so rapid monitor polls don't hammer remote hosts. function vv_remote_hosts_stats(): array { // Read ALL conf files — remote host keys live in their own host*.conf, not the current host's. + // + // The RAM cache is read first and wins, because it is the only current copy of a partner conf. + // conf_sync.sh pulls each partner's live conf into VV_CONF_RAM_CACHE_DIR; load_config.sh has + // sourced partner vars from there rather than from disk for as long as the cache has existed, + // but this glob never did — so PHP and bash could disagree about the same partner. Any + // host*.conf still sitting in CONF_DIR for a host that is not this one is a leftover from + // before sparse checkout, and is stale by definition. $vars = vv_conf_vars(); - foreach (glob(CONF_DIR . '/host*.conf') ?: [] as $f) { + $confFiles = array_merge( + glob(VV_CONF_RAM_CACHE_DIR . '/host*.conf') ?: [], + glob(CONF_DIR . '/host*.conf') ?: [] + ); + foreach ($confFiles as $f) { $raw = file_get_contents($f) ?: ''; preg_match_all('/^\s*([A-Z0-9_]+)\s*=\s*["\']?([^"\'#\n]*?)["\']?\s*(?:#.*)?$/m', $raw, $m); foreach ($m[1] as $i => $key) { diff --git a/System_Essentials/conf_cache_restore.sh b/System_Essentials/conf_cache_restore.sh index 6c96e5c..9134aae 100755 --- a/System_Essentials/conf_cache_restore.sh +++ b/System_Essentials/conf_cache_restore.sh @@ -103,7 +103,7 @@ # Reboot-surviving backup written by conf_cache_save.sh. Consumed and cleared here. # # CONF_RAM_CACHE_DIR -# Destination RAM cache (tmpfs, /tmp/.cache/vv/d) that load_config.sh reads +# Destination RAM cache (tmpfs, /tmp/varaverk/conf) that load_config.sh reads # partner vars from. # # PARTNERSHIP_ENABLED diff --git a/System_Essentials/conf_cache_save.sh b/System_Essentials/conf_cache_save.sh index 5bdf995..edc1a3b 100755 --- a/System_Essentials/conf_cache_save.sh +++ b/System_Essentials/conf_cache_save.sh @@ -93,7 +93,7 @@ # ${SCRIPTS_DIR}, so it follows the active storage mode. # # CONF_RAM_CACHE_DIR -# Source RAM cache (tmpfs, /tmp/.cache/vv/d) populated by conf_sync.sh. +# Source RAM cache (tmpfs, /tmp/varaverk/conf) populated by conf_sync.sh. # # PARTNERSHIP_ENABLED # Checked via require_partnership(). diff --git a/System_Essentials/conf_sync.sh b/System_Essentials/conf_sync.sh index ccf085e..98b8f90 100755 --- a/System_Essentials/conf_sync.sh +++ b/System_Essentials/conf_sync.sh @@ -5,19 +5,19 @@ # # PURPOSE # ───────────────────────────────────────────────────────────────────────────── -# Maintains a RAM-resident conf cache at /tmp/.cache/vv/d/. +# Maintains a RAM-resident conf cache at /tmp/varaverk/conf/. # Credentials and partner keys live in RAM only — never on disk across hosts. # # On array start (default / --array-start): # 1. Copy own conf to local cache # 2. Pull each available partner's conf from their disk → local cache -# 3. Push own conf to each available partner's /tmp/.cache/vv/d/ cache +# 3. Push own conf to each available partner's /tmp/varaverk/conf/ cache # # On conf save (--push-only): -# Fast path — push updated own conf to all partners' /tmp/.cache/vv/d/ only. +# Fast path — push updated own conf to all partners' /tmp/varaverk/conf/ only. # No pulls, no local cache rebuild. # -# Cache is /tmp/.cache/vv/d (tmpfs) — cleared every reboot, repopulated by +# Cache is /tmp/varaverk/conf (tmpfs) — cleared every reboot, repopulated by # this script on next array start. Scripts source from cache for partner vars; # own vars always come from disk (load_config.sh skips cached copy of own conf). # @@ -45,7 +45,7 @@ # # RAM-Only Credentials # Partner credentials and keys never touch disk on the receiving server. -# /tmp/.cache/vv/d is tmpfs — cleared every reboot. This is intentional: +# /tmp/varaverk/conf is tmpfs — cleared every reboot. This is intentional: # partner conf files are not discoverable on disk between boots. # # Pull Resolves Remote Path @@ -104,7 +104,7 @@ # Master toggle for conf syncing (default: true) # # CONF_RAM_CACHE_DIR -# tmpfs cache both ends read partner vars from (/tmp/.cache/vv/d). Cleared every +# tmpfs cache both ends read partner vars from (/tmp/varaverk/conf). Cleared every # reboot, which is why conf_cache_save.sh / conf_cache_restore.sh exist. # # SSH_KEY @@ -245,7 +245,7 @@ for host_var in $(compgen -v | grep -E '^HOST[0-9]+$' | sort); do fi fi - # ── Push: send own conf to partner's /tmp/.cache/vv/d/ cache ─────────── + # ── Push: send own conf to partner's /tmp/varaverk/conf/ cache ─────────── if [[ "$PULL_ONLY" == true ]]; then continue fi diff --git a/load_config.sh b/load_config.sh index f010fbd..260289b 100755 --- a/load_config.sh +++ b/load_config.sh @@ -173,7 +173,7 @@ fi # ━━━ Source partner confs from /tmp cache ━━━ -# conf_sync.sh pulls partner host*.conf files into /tmp/.cache/vv/d/ +# conf_sync.sh pulls partner host*.conf files into /tmp/varaverk/conf/ # on array start and after any conf save. Sourcing them here makes partner vars # (HOST2_*, HOST3_*, …) available without committing credentials to the git repo # or violating sparse checkout — partner confs live in RAM only, cleared on reboot.