From 420e13a7468c4e9975b29e027a02315b0813f8fb Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Sun, 14 Jun 2026 01:46:51 -0400 Subject: [PATCH] Resolve bash variable references in vv_conf_vars() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHP reads master.conf values like STATE_DIR="${SCRIPTS_DIR}/State_Files" literally — the ${SCRIPTS_DIR} token is never expanded, so any PHP code using the returned STATE_DIR value got an invalid path. Two-pass resolution: SCRIPTS_DIR first (from PHP constant), then remaining ${VAR} tokens using the now-resolved var set (covers DATA_DIR-based paths like ARR_SYNC_BLOCKLIST). --- Plugin/unraid/include/config.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Plugin/unraid/include/config.php b/Plugin/unraid/include/config.php index c43c2f6..4eee967 100644 --- a/Plugin/unraid/include/config.php +++ b/Plugin/unraid/include/config.php @@ -206,6 +206,20 @@ function vv_conf_vars(): array { $vars[$key] = str_replace('\\$', '$', trim($m[2][$i])); } } + // Resolve bash variable references — bash expands ${VAR} at runtime; PHP reads them literally. + // Pass 1: ${SCRIPTS_DIR} from the PHP-computed constant (other vars depend on it). + // Pass 2: ${VAR} using now-resolved values from within the same conf set. + foreach ($vars as $k => &$v) { + if (is_string($v)) $v = str_replace('${SCRIPTS_DIR}', SCRIPTS_DIR, $v); + } + foreach ($vars as $k => &$v) { + if (is_string($v) && str_contains($v, '${')) { + $v = preg_replace_callback('/\$\{([A-Z0-9_]+)\}/', function ($m) use ($vars) { + return $vars[$m[1]] ?? $m[0]; + }, $v); + } + } + unset($v); return $vars; }