Files
ubuntu-bare-metal/stacks/server-ui/scripts/print-api-key-instructions.sh
T
tomasz-syn-grzegorza 359afb3a59 Initial import: bare-metal stacks, Server UI, GPU fan, tutorials.
Infrastructure configs for GMKtec K11 (Docker, vLLM, LocalAI, ComfyUI,
control-plane, gpu-fan agent, Server UI with CLI/file explorer/GPU fan curve).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-05 12:02:04 +00:00

58 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Print API key + browser instructions (shared by install scripts and show-api-key.sh).
set -euo pipefail
print_api_key_instructions() {
local env_file="${1:-/opt/control-plane/.env}"
local ui_port="${2:-8091}"
local api_key=""
local lan_ip=""
if [[ -r "${env_file}" ]]; then
api_key="$(grep '^API_KEY=' "${env_file}" 2>/dev/null | cut -d= -f2- || true)"
elif [[ -f "${env_file}" ]]; then
api_key="$(sudo grep '^API_KEY=' "${env_file}" 2>/dev/null | cut -d= -f2- || true)"
fi
lan_ip="$(hostname -I 2>/dev/null | awk '{print $1}')"
[[ -n "${lan_ip}" ]] || lan_ip="<IP-serwera>"
echo ""
echo "══════════════════════════════════════════════"
echo " SERVER UI — KLUCZ API"
echo "══════════════════════════════════════════════"
echo ""
if [[ -z "${api_key}" ]]; then
echo "Brak API_KEY w ${env_file}"
echo "Uruchom: sudo bash stacks/server-ui/scripts/setup-control-plane-env.sh"
echo ""
return 1
fi
echo "1. Twój klucz API (skopiuj):"
echo ""
echo " ${api_key}"
echo ""
echo "2. Otwórz panel (klucz zapisze się w przeglądarce):"
echo ""
echo " http://${lan_ip}:${ui_port}/?api_key=${api_key}"
echo ""
echo "3. Albo ręcznie:"
echo " a) Wejdź na http://${lan_ip}:${ui_port}/"
echo " b) Wklej klucz w pole „API Key”"
echo " c) Kliknij „Zapisz”"
echo " d) Kliknij „Sprawdź klucz” (powinno być: Klucz poprawny)"
echo " e) Dopiero potem Start/Stop, CLI, Pliki, GPU Fan"
echo ""
echo "Plik klucza (na przyszłość):"
echo " sudo grep ^API_KEY= ${env_file}"
echo ""
echo "══════════════════════════════════════════════"
echo ""
}
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
print_api_key_instructions "${1:-/opt/control-plane/.env}" "${2:-8091}"
fi