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; }