diff --git a/Plugin/unraid/api/storage.php b/Plugin/unraid/api/storage.php index dd55e41..c91987d 100644 --- a/Plugin/unraid/api/storage.php +++ b/Plugin/unraid/api/storage.php @@ -96,15 +96,14 @@ if ($action === 'detect' && $_SERVER['REQUEST_METHOD'] === 'POST') { } // ── Unraid API key status ───────────────────────────────────────────────────── -// Keys live in host*.conf (private, not master.conf): -// host1.conf: HOST1_UNRAID_API_KEY (own) + HOST2_UNRAID_API_KEY (HOST1's access to HOST2) -// host2.conf: HOST2_UNRAID_API_KEY (own) + HOST1_UNRAID_API_KEY (HOST2's access to HOST1) if ($action === 'api_status') { require_once dirname(__DIR__) . '/include/unraid_api.php'; $localStatus = vv_api_get_status(); $vars = vv_conf_vars(); $myHost = vv_detect_host(); $myId = strtoupper($myHost); + $hn = trim((string)shell_exec("hostname -s 2>/dev/null | sed 's/^[Uu][Nn][Rr][Aa][Ii][Dd]-//'")) ?: 'Varaverk'; + $localKeyName = 'Varaverk ' . $hn; $hosts = []; foreach ($vars as $k => $v) { @@ -113,14 +112,11 @@ if ($action === 'api_status') { $keyVar = $id . '_UNRAID_API_KEY'; $key = $vars[$keyVar] ?? ''; $isLocal = ($id === $myId); - // For local: key is Varaverk_HOST1 registered on own machine - // For remote: key is Varaverk_HOST1 registered on HOST2's machine (stored in host1.conf) $hosts[] = [ 'host_id' => $id, 'hostname' => $v, 'is_local' => $isLocal, 'key_var' => $keyVar, - 'key_name' => 'Varaverk_' . ($isLocal ? $myId : $myId), // Varaverk_HOST1 on that registry 'key_present' => !empty($key), 'key_preview' => $key ? substr($key, 0, 8) . '...' . substr($key, -4) : null, 'api_ok' => $isLocal @@ -133,6 +129,7 @@ if ($action === 'api_status') { echo json_encode([ 'ok' => true, 'my_id' => $myId, + 'key_name' => $localKeyName, 'hosts' => $hosts, 'fallbacks' => $localStatus['fallbacks'], ]); @@ -145,11 +142,9 @@ if ($action === 'setup_apikeys' && $_SERVER['REQUEST_METHOD'] === 'POST') { if (!file_exists($script)) { echo json_encode(['ok' => false, 'error' => 'unraid_api_key_renew.sh not found']); exit; } - $allHosts = ($_POST['all_hosts'] ?? '0') === '1'; - $flags = $allHosts ? ' --all-hosts' : ''; set_time_limit(60); $output = []; $exit = 0; - exec('bash ' . escapeshellarg($script) . $flags . ' 2>&1', $output, $exit); + exec('bash ' . escapeshellarg($script) . ' 2>&1', $output, $exit); echo json_encode(['ok' => $exit === 0, 'exit' => $exit, 'output' => implode("\n", $output)]); exit; } diff --git a/Plugin/unraid/pages/settings.php b/Plugin/unraid/pages/settings.php index 2009a9e..67cce58 100644 --- a/Plugin/unraid/pages/settings.php +++ b/Plugin/unraid/pages/settings.php @@ -13,10 +13,6 @@ $_enableLogging = ($_vars['ENABLE_LOGGING'] ?? 'false') === 'true'; $_discordKey = $_myId . '_DISCORD_WEBHOOK'; $_discordHook = $_vars[$_discordKey] ?? ''; -// API key -$_apiKeyVar = $_myId . '_UNRAID_API_KEY'; -$_apiKey = $_vars[$_apiKeyVar] ?? ''; -$_apiPreview = $_apiKey ? substr($_apiKey, 0, 8) . '...' . substr($_apiKey, -4) : ''; ?>