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

@ -57,11 +57,19 @@ Either way, the service starts on boot and restarts if it crashes.
### 1. The hub
The repo is private, so fetching the installer needs a read-only Gitea token (Settings → Applications → Access tokens, scope `read:repository`). The token is read without echoing it or saving it in history, and the installer reuses it to clone:
```bash
curl -fsSL https://git.neilbantoc.dev/services/network-monitor/raw/branch/main/install.sh | bash
read -rsp 'Gitea token: ' GIT_TOKEN && export GIT_TOKEN && curl -fsSL -H "Authorization: token $GIT_TOKEN" https://git.neilbantoc.dev/services/network-monitor/raw/branch/main/install.sh | bash
```
Inside an LXC you are root, so that's it. On another Linux machine in native mode, use `| sudo env INSTALL_MODE=native bash`.
Inside an LXC you are root, so that's it. On another Linux machine in native mode, use `| sudo -E env INSTALL_MODE=native bash`. If the raw URL gives a 404 even with the token, clone and run the installer instead:
```bash
git clone https://git.neilbantoc.dev/services/network-monitor.git /tmp/nm && bash /tmp/nm/install.sh
```
The token is saved in `/opt/network-monitor/.env` (`GIT_TOKEN`) so `update` can fetch. Only the update step sees it, not the running app.
Then connect AdGuard Home in `/opt/network-monitor/.env`:
@ -77,19 +85,18 @@ Open `http://<hub-ip>:8000`. The hub listens on the LAN (`HOST_BIND=0.0.0.0`) be
### 2. Probes
On the hub, open **Probes → Add probe** and give the probe a name. The hub shows a command with that probe's token. Open the hub at its LAN address, not `localhost`, so the command has a `HUB_URL` the probe can reach. Run it on the probe machine:
On the hub, open **Probes → Add probe** and give the probe a name. The hub shows a command with that probe's token. The hub serves the installer itself, so fetching it needs no Gitea access. Open the hub at its LAN address, not `localhost`, so the command has a `HUB_URL` the probe can reach. Run it on the probe machine:
```bash
# Linux host (Docker), or an LXC as root (native, detected automatically)
curl -fsSL https://git.neilbantoc.dev/services/network-monitor/raw/branch/main/install-probe.sh | HUB_URL=http://192.168.1.10:8000 PROBE_TOKEN=... bash
# Linux host (Docker), an LXC as root (native, detected automatically), or macOS as your user
curl -fsSL http://192.168.1.10:8000/install-probe.sh | HUB_URL=http://192.168.1.10:8000 PROBE_TOKEN=... bash
# Linux, native, not root
curl -fsSL https://git.neilbantoc.dev/services/network-monitor/raw/branch/main/install-probe.sh | sudo env HUB_URL=http://192.168.1.10:8000 PROBE_TOKEN=... bash
# macOS: as your own user (it asks for sudo when it needs it)
curl -fsSL https://git.neilbantoc.dev/services/network-monitor/raw/branch/main/install-probe.sh | HUB_URL=http://192.168.1.10:8000 PROBE_TOKEN=... bash
curl -fsSL http://192.168.1.10:8000/install-probe.sh | sudo env HUB_URL=http://192.168.1.10:8000 PROBE_TOKEN=... bash
```
Because the repo is private, the installer asks for a read-only Gitea token on the terminal before it clones. To skip the prompt, put `GIT_TOKEN=...` before `bash`.
The probe's test server listens on port 8765 (`PROBE_PORT`) on all interfaces.
**Ping on Linux.** Linux needs unprivileged ping allowed (`net.ipv4.ping_group_range`). The installer sets it and persists it in `/etc/sysctl.d/60-network-probe-ping.conf`. That needs root. Without it, the probe skips ping and keeps its HTTP, DNS and throughput checks.
@ -108,7 +115,7 @@ pct create 210 local:vztmpl/debian-12-standard_12.12-1_amd64.tar.zst \
--net0 name=eth0,bridge=vmbr0,ip=dhcp --unprivileged 1 --features nesting=1 --onboot 1
pct start 210 && pct enter 210
apt update && apt install -y curl # if the template lacks curl
curl -fsSL https://git.neilbantoc.dev/services/network-monitor/raw/branch/main/install-probe.sh | HUB_URL=http://<hub-ip>:8000 PROBE_TOKEN=... bash
curl -fsSL http://<hub-ip>:8000/install-probe.sh | HUB_URL=http://<hub-ip>:8000 PROBE_TOKEN=... bash
```
- **`nesting=1`:** Debian 12's systemd needs it in an unprivileged container. New containers get it by default on recent Proxmox.
@ -130,11 +137,10 @@ On the VPS, run `install-probe.sh` with no `HUB_URL` or `PROBE_TOKEN`, and open
### Private repo
If the repo is private, both installers ask for a read-only token. To avoid echoing it or saving it in shell history:
```bash
read -rsp 'Git token: ' GIT_TOKEN && export GIT_TOKEN && curl -fsSL -H "Authorization: Bearer $GIT_TOKEN" https://git.neilbantoc.dev/services/network-monitor/raw/branch/main/install-probe.sh | HUB_URL=... PROBE_TOKEN=... bash
```
- **Fetching:** the hub installer comes from Gitea with a token (above), and probe installers come from the hub.
- **Cloning:** both installers clone with `GIT_TOKEN` and ask for it on the terminal if they can't read the repo.
- **Storage:** the token goes into that machine's `.env` for later updates.
- **Revoking:** use a read-only token per machine, so one can be revoked without touching the others.
## Deploy changes