26 Commits

Author SHA1 Message Date
Cobra d1e89bddf5 Add three dynamic infrastructure auto-suppression mechanisms to net_alerter
- Option A: OUI-based auto-exclusion for network equipment (Ubiquiti, Cisco, Aruba, TP-Link, Netgear, MikroTik, Ruckus)
- Option B: Churn-based suppression (cycles 3+ times in 30min auto-suppresses device)
- Option C: Verify NET_ALERTER_INFRA_IPS env var is documented and functional

Implementation:
- Added NETWORK_EQUIPMENT_OUIS set with 45 common network equipment OUI prefixes
- Added _check_churn() function to track departure events within 30min window
- Integrated OUI check into on_arrival() and seed_infrastructure_ips()
- Integrated churn check into on_departure() before timer start
- Enhanced seed_infrastructure_ips() docstring to document all 5 seeding steps
- Removed interactive BB_ALERTER_INFRA_IPS prompt from operator_setup.sh (post-deploy config only)
2026-04-10 22:57:40 -04:00
Cobra 98ee896916 Add NET_ALERTER_INFRA_IPS config to setup.sh .env template and operator_setup.sh prompt 2026-04-10 22:50:56 -04:00
Cobra 40eb8cf621 Restore execute permission on operator_setup.sh 2026-04-10 06:32:31 -04:00
Cobra 47e45453a7 Add BLE alerter configuration to operator_setup.sh (mode, devices, timeout, Matrix creds) 2026-04-10 06:32:29 -04:00
Cobra 019a96b205 Fix flash bugs: remove netplan wifi conflict, suppress eth default route, force IPv4 for Tailscale install
- Remove 20-wifi.yaml netplan block (Bug 1): causes netplan to spawn its own wpa_supplicant instance, which claims ctrl_iface and blocks wpa_supplicant@wlan0.service. The per-interface systemd service is the correct approach.
- Add cleanup line to remove any pre-existing 20-wifi.yaml from the Armbian image.
- Patch 10-dhcp-all-interfaces.yaml to suppress default route on ethernet (Bug 2): without this, ethernet DHCP default route metric 100 beats WiFi metric 1024, routing internet traffic to ethernet which has no upstream. Causes Tailscale and firstboot to fail.
- Force IPv4 resolution in Tailscale curl (Bug 3): some homelab/ISP networks lack IPv6 internet routes. IPv6 DNS resolution for tailscale.com causes immediate curl failure on first boot.
2026-04-08 19:37:38 -04:00
Cobra 248ba78e15 Fix WiFi: enable wpa_supplicant@wlan0 — instance was never linked 2026-04-08 15:56:48 -04:00
Cobra 3cdccbf47d Fix WiFi conflict and SSH accessibility on fresh flash
- Remove wpa_supplicant@wlan0.service enablement: Netplan spawns its own
  wpa_supplicant instance, enabling the @wlan0 unit creates a second one
  that fights for the socket, causing WiFi instability and SSH drops
- Write /etc/nftables.conf to card at flash time: Armbian bookworm default
  nftables policy drops all input; SSH was unreachable despite sshd running.
  Ruleset allows established, loopback, ICMP, and TCP/22 only

Fixes DevTrack #317 and #295
2026-04-08 11:08:02 -04:00
Cobra d66b547045 Fix wpa_supplicant conflict and firstboot robustness
- Remove generic wpa_supplicant.service symlink when wpa_supplicant@wlan0 is enabled — both services fight over wlan0 causing WiFi instability and SSH drops
- Add udev rule to disable WiFi power saving (aw859a drops connections under load with power save on)
- Drop set -e from firstboot script so a failing step does not kill the whole run
- Guard setup.sh call — skip gracefully if not present (dev/test scenario)

Fixes #295 and #296
2026-04-07 21:50:51 -04:00
Cobra 1803c54182 Switch WiFi config from NetworkManager to Netplan+wpa_supplicant
Armbian minimal uses systemd-networkd+wpa_supplicant via Netplan, not NM.
Write Netplan YAML, wpa_supplicant-wlan0.conf, and networkd .network file.
Enable wpa_supplicant@wlan0.service via symlink if template exists.
2026-04-07 17:02:36 -04:00
Cobra d2f4f9759d Fix SD flash mounting wrong partition — Armbian p1=boot p2=rootfs
WiFi, SSH keys, root password, firstboot service were all being written to
the FAT32 boot partition (p1) instead of the ext4 rootfs (p2). Detect the
ext4 partition by filesystem type and mount that as MOUNT_POINT.
2026-04-07 16:44:22 -04:00
Cobra 61a1756dae Fix mktemp overwrite prompt in autossh tunnel keygen 2026-04-07 15:56:59 -04:00
Cobra 56ad5662ac Fix ssh-keygen overwrite prompt and key landing in root home
mktemp creates the file before ssh-keygen runs — keygen sees it exists
and prompts. Switch to mktemp -d so keygen writes a fresh file.

When run via sudo SUDO_USER is set but HOME=/root. Resolve the real
home via getent so the key lands in the operator's ~/.ssh, not root's.
2026-04-07 15:47:31 -04:00
Cobra 6cb48909b2 Save generated SSH key locally to ~/.ssh/bb-<device_id>
Infisical is the backup copy. Local key at a predictable path means
no hunting — ssh -i ~/.ssh/bb-<device_id> just works.
2026-04-07 15:22:55 -04:00
Cobra 42c05f37e6 Fix ANSI rendering and Infisical key storage in operator wizard
echo calls in summary/final sections were missing -e flag so ANSI
escape codes printed literally instead of rendering.

Infisical SSH key storage was targeting a non-existent 'bigbrother'
folder, silently failing to store the private key. Removed folder
argument so keys store at root where creds CLI can retrieve them.
2026-04-07 15:22:16 -04:00
Cobra e00769631a Remove homeserver default — no infrastructure fingerprints in wizard 2026-04-07 14:56:46 -04:00
Cobra 4c332eabb4 Proper Matrix alerter support with client API
Matrix doesn't use a simple webhook URL — needs homeserver, room ID,
and bot token separately. Uses PUT /_matrix/client/v3/rooms/.../send
with Bearer token auth. Room ID is bash-encoded (! → %21, : → %3A)
to avoid Python dependency pre-setup. Also adds ntfy and plain
webhook as options under a typed alerter menu.
2026-04-07 14:55:23 -04:00
Cobra 84f0775f76 Align device ID with MAC profile OUI for consistent network identity
Device ID is now a MAC-format hex string (12 chars) using the same
OUI as the randomly selected device profile. If the device gets an
Amazon OUI for its MAC, the device ID starts with fc65de. Hostname,
MAC, and device ID all point to the same vendor — no inconsistency
for anyone watching the network.
2026-04-07 14:48:22 -04:00
Cobra d8de49a53d Remove bb- prefix from device ID default
bb- prefix is a tool fingerprint — visible in Infisical key names,
alerter payloads, and config files on the device. Default is now
a plain 10-char hex string with no identifying prefix.
2026-04-07 14:44:59 -04:00
Cobra af124cc6d0 Default VPN to Tailscale, add auth key expiry warning
Tailscale handles NAT traversal automatically via DERP relay — more
reliable than WireGuard for devices landing on unknown networks.
Add reminder to use reusable non-expiring keys for long-term drops.
2026-04-07 14:41:17 -04:00
Cobra b0fb5af1fb Include device IP and hostname in firstboot alerter beacon
Blind drops need some way to locate the device when no VPN is selected.
Alerter now reports public IP (via ipify) with fallback to local IP,
plus hostname — gives enough info to SSH directly on same-network drops.
2026-04-07 14:37:04 -04:00
Cobra 2b00b28de6 Add reverse SSH tunnel (autossh) as VPN option in operator wizard
Generates a dedicated tunnel keypair during setup, prints public key
for operator to pre-stage on server, writes private key to SD card.
On first boot: installs autossh, writes bb-tunnel.service with
correct RemoteForward and reconnect settings. Zero network traffic
until operator initiates connection through the tunnel port.
2026-04-07 14:30:10 -04:00
Cobra ae79d64913 Align default hostname with MAC device profiles for OPSEC consistency 2026-04-07 14:19:55 -04:00
Cobra 2b53da80d0 Fix wizard: defaults for all prompts, random hostname/device-id, download robustness
- Add prompt_default() helper: shows defaults, accepts Enter to use them
- WiFi: default=n (skip), keeps passphrase prompt loop
- Root password: auto-generate with openssl, show in summary if used, operator can override
- SSH key: default=1 (generate new)
- Device ID: auto-generate bb-<8-char-uuid>
- Boot mode: default=1 (passive)
- VPN: default=1 (none)
- Hostname: NEW section with auto-generated node-<6-char-uuid> default
- Alerter: default=n (disabled)
- Download: use curl -L (no -f), verify file exists and >50MB
- Config summary: show hostname, mask password (show auto-generated clearly)
- Apply config: write BB_HOSTNAME to /etc/hostname and /etc/hosts
- No eval with user input: use printf -v for variable assignment
2026-04-07 14:17:01 -04:00
Cobra ae35f3f7b8 Fix HOME path when run via sudo — use SUDO_USER's home not /root 2026-04-07 14:12:07 -04:00
Cobra 6f2a6dacea Fix SCRIPT_DIR path now that operator_setup.sh is at repo root 2026-04-07 14:05:36 -04:00
Cobra 8e7e3fe91d Move operator_setup.sh to repo root for direct access 2026-04-07 14:05:12 -04:00