Files
tomasz-syn-grzegorza 73e4fc005e Add stack Update, ComfyUI model manager, and slim ComfyUI stack.
Server UI gains Update on stack cards, ComfyUI Models tab with workflow
scan and downloads, and centralized comfyui_config. Model catalog and
download scripts move from stacks/comfyui to server-ui so ComfyUI stays a
minimal Docker wrapper for easier image updates.
2026-07-05 18:45:17 +00:00

109 lines
3.7 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Print API key + browser instructions (shared by install scripts and show-api-key.sh).
set -euo pipefail
_read_api_key() {
local env_file="$1"
local api_key=""
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
if [[ -z "${api_key}" ]]; then
local pid
pid="$(pgrep -f '/opt/server-ui/app.py' 2>/dev/null | head -1 || true)"
if [[ -n "${pid}" && -r "/proc/${pid}/environ" ]]; then
api_key="$(tr '\0' '\n' < "/proc/${pid}/environ" 2>/dev/null | grep '^API_KEY=' | cut -d= -f2- || true)"
fi
fi
printf '%s' "${api_key}"
}
print_api_key_instructions() {
local env_file="${1:-/opt/control-plane/.env}"
local ui_port="${2:-8091}"
local dev_env="${3:-}"
local api_key=""
local dev_key=""
local lan_ip=""
local verify_ok=0
api_key="$(_read_api_key "${env_file}")"
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
if [[ -n "${dev_env}" && -f "${dev_env}" ]]; then
dev_key="$(_read_api_key "${dev_env}")"
if [[ -n "${dev_key}" && "${dev_key}" != "${api_key}" ]]; then
echo "OSTRZEŻENIE: klucz dev różni się od produkcji!"
echo " prod: ${env_file}"
echo " dev: ${dev_env}"
echo " Napraw: sudo bash stacks/server-ui/scripts/setup-control-plane-env.sh"
echo ""
fi
fi
if curl -sf -X POST "http://127.0.0.1:${ui_port}/api/auth/verify" \
-H "Content-Type: application/json" \
-d "{\"api_key\":\"${api_key}\"}" >/dev/null 2>&1; then
verify_ok=1
fi
echo "Plik klucza: ${env_file}"
if [[ "${verify_ok}" -eq 1 ]]; then
echo "Weryfikacja live (server-ui :${ui_port}): OK"
else
echo "Weryfikacja live (server-ui :${ui_port}): FAIL"
echo " Sprawdź: systemctl status server-ui"
echo " Lub: bash stacks/server-ui/scripts/verify-api-key.sh"
fi
echo ""
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 "4. Stary klucz w przeglądarce?"
echo " a) W panelu kliknij „Wyczyść klucz”"
echo " b) Lub F12 → Application → Local Storage → usuń server-ui-api-key"
echo " c) Ctrl+F5, potem kroki 23"
echo ""
echo "Plik klucza (na przyszłość):"
echo " sudo grep ^API_KEY= ${env_file}"
echo ""
echo "══════════════════════════════════════════════"
echo ""
[[ "${verify_ok}" -eq 1 ]]
}
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
print_api_key_instructions "${1:-/opt/control-plane/.env}" "${2:-8091}" "${3:-}"
fi