LXC installs: announce <hostname>.local with Avahi, hub on port 80
In an LXC (lxc mode on a Proxmox node, or native mode inside an LXC), the installer now: - installs avahi-daemon (with the rlimit-nproc fix for unprivileged containers), so the container answers at <hostname>.local, and lists the web UI as a _http._tcp service - serves the hub on port 80 (CAP_NET_BIND_SERVICE for the netmon user) unless HOST_PORT is given, so http://netmon-hub.local works without a port - runs the inner install with LANG/LC_ALL=C.UTF-8 (no locale warnings from the node's LANG) and prints one summary, with the .local address When the UI is opened by a .local name, the Add probe command uses the hub's own IP for HUB_URL, since Linux probes usually can't resolve .local. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a96ae4e825
commit
cd2deda996
9 changed files with 136 additions and 17 deletions
|
|
@ -84,7 +84,8 @@ export -f pct pvesh pveam pvesm sleep id
|
|||
'''
|
||||
pve = tmp_path / "pve"
|
||||
pve.mkdir()
|
||||
env = {**os.environ, "NETMON_PVE_DIR": str(pve), "INSTALL_DIR": str(tmp_path / "opt"), "HOST_PORT": "8000"}
|
||||
env = {k: v for k, v in os.environ.items() if k != "HOST_PORT"}
|
||||
env.update({"NETMON_PVE_DIR": str(pve), "INSTALL_DIR": str(tmp_path / "opt"), "LANG": "en_US.UTF-8"})
|
||||
run = lambda: subprocess.run(["bash", "-c", stubs + "bash install.sh"], cwd=ROOT, capture_output=True, text=True, env=env, timeout=60)
|
||||
r = run()
|
||||
assert r.returncode == 0, r.stdout + r.stderr
|
||||
|
|
@ -97,8 +98,10 @@ export -f pct pvesh pveam pvesm sleep id
|
|||
assert part in create, part
|
||||
assert "pct start 105" in calls
|
||||
inner = next(line for line in calls.splitlines() if "netmon-install.sh" in line and "exec 105 -- env" in line)
|
||||
assert "INSTALL_MODE=native" in inner and "HOST_PORT=8000" in inner
|
||||
assert "http://192.168.68.50:8000" in r.stdout
|
||||
# Native inside, port 80 for the .local name, a locale the container has, one summary.
|
||||
for part in ("INSTALL_MODE=native", "HOST_PORT=80", "LC_ALL=C.UTF-8", "LANG=C.UTF-8", "NETMON_NESTED=1"):
|
||||
assert part in inner, part
|
||||
assert "http://netmon-hub.local (or http://192.168.68.50)" in r.stdout
|
||||
# The pushed script is a complete installer for the same role.
|
||||
text = pushed.read_text()
|
||||
assert "NETMON_ROLE=hub" in text and text.rstrip().endswith('main "$@"')
|
||||
|
|
@ -139,3 +142,10 @@ export -f pct pvecm pvesm id
|
|||
r = subprocess.run(["bash", "-c", stubs + "bash install.sh"], cwd=ROOT, capture_output=True, text=True, env=env, timeout=60)
|
||||
assert r.returncode != 0 and "without quorum" in r.stderr and "pvecm expected 1" in r.stderr
|
||||
assert not (tmp_path / "calls").exists() # stopped before touching pct or storage
|
||||
|
||||
|
||||
def test_explicit_port_wins_over_lan_default(tmp_path):
|
||||
base = FUNCS + 'KEYS="INSTALL_MODE HOST_PORT"; PASSED=" "; log() { :; }; is_lxc() { return 0; }; id() { echo 0; }; ROLE=hub; PORT_KEY=HOST_PORT; '
|
||||
pick = 'CALLER_MODE=; choose_mode; if [ "$ROLE" = hub ] && [ -z "$CALLER_PORT" ] && uses_lan_name; then HOST_PORT=80; fi; echo "$MODE $HOST_PORT"'
|
||||
assert bash(base + 'CALLER_PORT=; HOST_PORT=8000; ' + pick, INSTALLER="install.sh").stdout.strip() == "native 80"
|
||||
assert bash(base + 'CALLER_PORT=9000; HOST_PORT=9000; ' + pick, INSTALLER="install.sh").stdout.strip() == "native 9000"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue