Serve installers from the hub; document the private-repo install

The repo is private, so anonymous raw URLs return 404. The hub now serves
/install-probe.sh (and /install.sh) from its own checkout, open even with
UI_PASSWORD, and the Add probe command fetches from there. The installers
still ask for a read-only token to clone. Docs use Gitea's
"Authorization: token" header and give a git-clone fallback for the hub.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-04 18:13:19 -08:00
parent 54a765510a
commit efd3836945
10 changed files with 60 additions and 24 deletions

View file

@ -10,7 +10,7 @@ import secrets
from pathlib import Path
from fastapi import APIRouter, FastAPI, HTTPException, Request
from fastapi.responses import FileResponse, JSONResponse, Response
from fastapi.responses import FileResponse, JSONResponse, PlainTextResponse, Response
from fastapi.staticfiles import StaticFiles
from app.hub import adguard, db, dns, health, probes, settings
@ -63,7 +63,7 @@ async def _adguard_error(_req, exc):
return JSONResponse({"detail": str(exc), "code": "adguard_error"}, status_code=502)
OPEN_PATHS = ("/healthz", "/api/probe/report")
OPEN_PATHS = ("/healthz", "/api/probe/report", "/install-probe.sh", "/install.sh")
@app.middleware("http")
@ -106,6 +106,18 @@ api.include_router(dns.router)
app.include_router(api, prefix="/api")
ROOT = Path(__file__).resolve().parent.parent.parent
@app.get("/install-probe.sh", include_in_schema=False)
@app.get("/install.sh", include_in_schema=False)
def installer(request: Request) -> PlainTextResponse:
"""The installers, served from the hub's own checkout so a private repo needs no raw-file
access: curl -fsSL http://<hub>:8000/install-probe.sh | HUB_URL=... PROBE_TOKEN=... bash"""
name = request.url.path.lstrip("/")
return PlainTextResponse((ROOT / name).read_text(), media_type="text/x-shellscript", headers={"Cache-Control": "no-cache"})
@app.get("/healthz", include_in_schema=False)
def healthz() -> dict:
return {"status": "ok", "version": VERSION, "role": "hub"}