Hub (FastAPI + no-build web UI): - Network health: live probe/target matrix, status strips, incidents - Probes: add (with install command), rename, remove, latency and throughput charts - Clients merged from AdGuard, DHCP, query log and probe ARP tables; names, categories, suspicious flag, notes, per-client DNS requests - Query log, domain detail (clients, related subdomains), blocked domains via the AdGuard Home /control API Probe: tests peers (ping, HTTP, throughput), gateway, LAN and public DNS, internet URLs and an optional VPS; buffers results while the hub is down. Gateway and ARP from /proc/net on Linux, route/arp on macOS. Install: install.sh (hub) and install-probe.sh (generated from it), each in docker mode (compose; default on Linux hosts) or native mode (venv + systemd or launchd; default on macOS and in LXC). Both modes deploy with an update command that checks the new commit and rolls back on failure. CLAUDE.md carries shared context for Claude Code sessions on each machine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
3.1 KiB
Bash
Executable file
59 lines
3.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Generate install-probe.sh from install.sh. install.sh is the only installer you edit; the
|
|
# probe installer is the same script with NETMON_ROLE=probe and its own header comment.
|
|
# tests/test_installers.py fails when install-probe.sh is out of date.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
RAW=https://git.neilbantoc.dev/services/network-monitor/raw/branch/main
|
|
out=install-probe.sh
|
|
[ "${1:-}" = --check ] && out=$(mktemp)
|
|
{
|
|
cat <<HEADER
|
|
#!/usr/bin/env bash
|
|
# GENERATED from install.sh by scripts/build-installers.sh. Edit install.sh, then run that script.
|
|
#
|
|
# Install (or upgrade) a Network Monitor PROBE. The hub's "Add probe" dialog prints the exact
|
|
# command, with this probe's token:
|
|
#
|
|
# curl -fsSL $RAW/install-probe.sh | HUB_URL=http://hub:8000 PROBE_TOKEN=... bash
|
|
#
|
|
# Native mode on Linux (Proxmox LXC, bare metal) runs as root:
|
|
# curl -fsSL $RAW/install-probe.sh | sudo env HUB_URL=http://hub:8000 PROBE_TOKEN=... bash
|
|
#
|
|
# Serve-only probe (e.g. a VPS the others test against): leave out HUB_URL and PROBE_TOKEN,
|
|
# and open PROBE_PORT (default 8765/tcp) in its firewall.
|
|
#
|
|
# Private repo over https: add GIT_TOKEN, read without echoing it:
|
|
# read -rsp 'Git token: ' GIT_TOKEN && export GIT_TOKEN && curl -fsSL -H "Authorization: Bearer \$GIT_TOKEN" $RAW/install-probe.sh | HUB_URL=... PROBE_TOKEN=... bash
|
|
#
|
|
# Two ways to run (INSTALL_MODE):
|
|
# docker The probe in a container with host networking. Default on Linux hosts.
|
|
# native A Python virtualenv and a boot service: systemd on Linux, launchd on macOS.
|
|
# Default on macOS and inside LXC containers (e.g. Proxmox LXC).
|
|
# On Linux it also lets unprivileged processes ping (net.ipv4.ping_group_range, persisted in
|
|
# /etc/sysctl.d). Re-running is safe: it keeps .env (values you pass replace those keys).
|
|
# Ordinary deploys:
|
|
# docker: docker exec network-probe update
|
|
# native: sudo network-probe-update (macOS: network-probe-update)
|
|
#
|
|
# Settings (environment variables, all optional):
|
|
# HUB_URL, PROBE_TOKEN the hub to report to and this probe's token
|
|
# PROBE_PORT default 8765 (the probe's test server, on all interfaces)
|
|
# ADVERTISE_ADDR address other probes use for this one (default: what the hub sees)
|
|
# INSTALL_MODE docker | native (default: see above)
|
|
# INSTALL_DIR default /opt/network-probe
|
|
# REPO_URL, REPO_REF default https://git.neilbantoc.dev/services/network-monitor.git, main
|
|
# GIT_TOKEN, GIT_USERNAME private repo over https
|
|
# GIT_SSH_KEY private repo over SSH (base64-encoded deploy key)
|
|
#
|
|
# Everything is inside main(), so a partial download runs nothing. bash 3.2 compatible (macOS).
|
|
|
|
HEADER
|
|
sed -n '/^NETMON_ROLE=hub$/,$p' install.sh | sed '1s/^NETMON_ROLE=hub$/NETMON_ROLE=probe/'
|
|
} > "$out"
|
|
if [ "${1:-}" = --check ]; then
|
|
if cmp -s "$out" install-probe.sh; then rm -f "$out"; echo "install-probe.sh is up to date"; exit 0; fi
|
|
rm -f "$out"; echo "install-probe.sh is out of date: run scripts/build-installers.sh" >&2; exit 1
|
|
fi
|
|
chmod +x install-probe.sh
|
|
echo "wrote install-probe.sh"
|