diff --git a/drb-frontend/app/settings/nodes/page.tsx b/drb-frontend/app/settings/nodes/page.tsx index dc01f8a..1bebcf0 100644 --- a/drb-frontend/app/settings/nodes/page.tsx +++ b/drb-frontend/app/settings/nodes/page.tsx @@ -39,6 +39,23 @@ function EnrollmentTokensPanel() { const [label, setLabel] = useState(""); const [minting, setMinting] = useState(false); const [justMinted, setJustMinted] = useState(null); + const [cmdCopied, setCmdCopied] = useState(false); + const [tokenCopied, setTokenCopied] = useState(false); + + // The paste-ready one-shot install command for a fresh Pi. node id and the + // MQTT broker host aren't known here — left as placeholders the operator + // edits. C2 URL comes from this deployment's own config; the broker is the + // documented mqtt. sibling of the api host (install.sh header). + const c2Url = (process.env.NEXT_PUBLIC_C2_URL ?? "https://api.example.net").replace(/\/$/, ""); + const mqttBroker = (() => { + try { return `mqtt.${new URL(c2Url).hostname.replace(/^api\./, "")}`; } + catch { return "mqtt.example.net"; } + })(); + const installCmd = justMinted + ? `curl -fsSL https://git.vpn.cusano.net/logan/node-26/raw/tag/v1/install.sh \\ + | sudo bash -s -- --token ${justMinted} --node-id node-XXX \\ + --c2-url ${c2Url} --mqtt-broker ${mqttBroker}` + : ""; const load = useCallback(() => { c2api.listEnrollmentTokens() @@ -87,11 +104,40 @@ function EnrollmentTokensPanel() {

New token — copy it now, it won't be shown again:

-

{justMinted}

+ +
+

{justMinted}

+ +
+ +

+ …or run this on a fresh Pi (edit node-XXX and the broker host): +

+
+
{installCmd}
+ +
+