diff --git a/hosts/van.conf b/hosts/van.conf index 03580d5..6c0b0e7 100644 --- a/hosts/van.conf +++ b/hosts/van.conf @@ -2,10 +2,10 @@ # /etc/vanlink.conf -> this file. See hosts/vanlink.conf.example for the variable list. WIFI_5G_IFACE=wlp1s0 # MediaTek MT7925E (PCIe); 2.4GHz AP is the separate USB dongle below -WIFI_2G_IFACE=wlx3c3332002066 # D-Link USB dongle +WIFI_2G_IFACE=wlxf4f26d1760a7 # D-Link USB dongle (2.4GHz AP; the same dongle is listed in hosts/wan.conf — it moves between the hosts) LAN_IFACE=enP1p17s0 STARLINK_IFACE=enP2p33s0 -WIFI_WAN_IFACE= # none: no spare radio (the R5C's two radios are both APs) +WIFI_WAN_IFACE=wlx200bd04dc756 # Wi-Fi uplink test dongle (RTL8821CU); not always attached — van-failover treats an absent device as "not present" ONBOARD_LAN_IFACE= GATEWAY_IP="10.42.1.1" @@ -34,12 +34,13 @@ ENABLE_NVME_WATCH=0 # no NVMe on this board ENABLE_HA=1 ENABLE_FRIGATE=1 ENABLE_NM_WAN=1 -ENABLE_LEDS=1 # R5C front LEDs (van-leds) +CELLULAR_CONN_NAME=Koodo +CELLULAR_APN=sp.koodo.com + +# Front LEDs +ENABLE_LEDS=1 # R5C front LEDs (van-leds) LED_POWER=red:power LED_LAN=green:lan LED_WAN=green:wan LED_WLAN=green:wlan - -CELLULAR_CONN_NAME=Koodo -CELLULAR_APN=sp.koodo.com diff --git a/tests/check-templates.sh b/tests/check-templates.sh index 0ba4c26..b01dd7d 100755 --- a/tests/check-templates.sh +++ b/tests/check-templates.sh @@ -50,6 +50,7 @@ done # 5. host-specific values land in the rendered output r() { VANLINK_CONF="hosts/$1.conf" ./deploy.sh render "$2"; } +hv() { ( . "hosts/$1.conf"; printf %s "${!2-}" ); } # hv : a value from a host file (so hardware changes need no test edits) expect() { # expect if r "$1" "$2" | grep -qF -- "$3"; then ok "$1: $2 has '$3'"; else bad "$1: $2 lacks '$3'"; fi } @@ -63,9 +64,9 @@ expect van ap/nftables.conf 'ip saddr 10.42.1.0/24' expect wan ap/nftables.conf 'ip saddr 10.42.0.0/24' expect van ap/van-br0-setup.service 'brctl addif br0 enP1p17s0' expect wan ap/van-br0-setup.service 'brctl addif br0 enx00e04c331140' -expect van failover/config.json '"device": ""' +expect van failover/config.json "\"device\": \"$(hv van WIFI_WAN_IFACE)\"" expect wan failover/config.json '"device": "wlan0"' -expect van router-status/config.json '"wifi_wan_iface": ""' +expect van router-status/config.json "\"wifi_wan_iface\": \"$(hv van WIFI_WAN_IFACE)\"" expect van failover/van-wlan-watchdog.service 'ExecStart=/usr/local/sbin/van-wlan-watchdog' expect wan failover/van-wlan-watchdog.service 'van-wlan-watchdog wlan0' expect van ap/van-ap-unmanaged.conf 'interface-name:enP1p17s0' @@ -75,7 +76,7 @@ expect van power/nvme-watch-config.json '"nvme_device": ""' expect wan ap/hostapd.conf 'interface=wlxc83a35a4ee55' expect van ap/hostapd.conf 'interface=wlp1s0' expect wan ap/hostapd-2g.conf 'interface=wlxf4f26d1760a7' -expect van ap/hostapd-2g.conf 'interface=wlx3c3332002066' +expect van ap/hostapd-2g.conf "interface=$(hv van WIFI_2G_IFACE)" expect_line wan ap/hostapd.conf 'ssid=VanLink' expect_line van ap/hostapd.conf 'ssid=VanLink2' expect_line wan ap/hostapd-2g.conf 'ssid=VanLink' @@ -216,7 +217,17 @@ tmpw=$(mktemp) VANLINK_CONF=hosts/wan.conf ./deploy.sh --render-wan-netplan > "$tmpw" if [ "$want" = "$(cat "$tmpw")" ]; then ok "wan.conf: split netplan renders identical to the old single template"; else bad "wan.conf: netplan render changed by the split"; diff <(echo "$want") "$tmpw" | head -10 | sed 's/^/ /' || true; fi if grep -qF '/etc/vanlink.conf' "$tmpw"; then bad "wan.conf: rendered netplan mentions /etc/vanlink.conf (a comment was re-edited; live hosts would report differs)"; else ok "wan.conf: rendered netplan keeps the original comments (no /etc/vanlink.conf)"; fi -if VANLINK_CONF=hosts/van.conf ./deploy.sh --render-wan-netplan | grep -q '^ wifis:'; then bad "van.conf: wifis stanza must be omitted (WIFI_WAN_IFACE empty)"; else ok "van.conf: no wifis stanza"; fi +# van's Wi-Fi uplink (if any) is whatever its host file names; the "no Wi-Fi WAN" path is covered with a synthetic conf +vw=$(hv van WIFI_WAN_IFACE) +vnp=$(VANLINK_CONF=hosts/van.conf ./deploy.sh --render-wan-netplan) +if [ -n "$vw" ]; then + if [[ $vnp == *" ${vw}:"* ]]; then ok "van.conf: wifis stanza names $vw"; else bad "van.conf: wifis stanza lacks $vw"; fi +else + if [[ $vnp == *" wifis:"* ]]; then bad "van.conf: wifis stanza must be omitted (WIFI_WAN_IFACE empty)"; else ok "van.conf: no wifis stanza"; fi +fi +nw=$(mktemp); sed -E 's/^WIFI_WAN_IFACE=[^[:space:]#]*/WIFI_WAN_IFACE=/' hosts/van.conf > "$nw" +nnp=$(VANLINK_CONF="$nw" ./deploy.sh --render-wan-netplan) +if [[ $nnp == *" wifis:"* ]]; then bad "empty WIFI_WAN_IFACE: wifis stanza must be omitted"; else ok "empty WIFI_WAN_IFACE: no wifis stanza"; fi rm -f "$tmpw" "$old" # 15. cellular connection name comes from the host config @@ -237,7 +248,10 @@ for h in van wan; do echo "$p" | grep -q '^wan-plan: ENABLE_NM_WAN=1$' && ok "$h: wan-plan header" || bad "$h: wan-plan header" echo "$p" | grep -q 'cellular profile: Koodo apn=sp.koodo.com' && ok "$h: wan-plan cellular" || bad "$h: wan-plan cellular" done -p=$(VANLINK_CONF=hosts/van.conf ./deploy.sh --wan-plan); echo "$p" | grep -q 'wifi WAN: none' && ok "van: wan-plan says no Wi-Fi WAN" || bad "van: wan-plan Wi-Fi WAN" +want_wp="wifi WAN: ${vw:-none}" +p=$(VANLINK_CONF=hosts/van.conf ./deploy.sh --wan-plan); [[ $p == *"$want_wp"* ]] && ok "van: wan-plan says '$want_wp'" || bad "van: wan-plan Wi-Fi WAN (want '$want_wp')" +p=$(VANLINK_CONF="$nw" ./deploy.sh --wan-plan); [[ $p == *"wifi WAN: none"* ]] && ok "empty WIFI_WAN_IFACE: wan-plan says no Wi-Fi WAN" || bad "empty WIFI_WAN_IFACE: wan-plan Wi-Fi WAN" +rm -f "$nw" p=$(VANLINK_CONF=hosts/wan.conf ./deploy.sh --wan-plan); echo "$p" | grep -q 'wifi WAN: wlan0' && ok "wan: wan-plan Wi-Fi WAN wlan0" || bad "wan: wan-plan Wi-Fi WAN" # CELLULAR_UUID is derived in pure bash (no uuidgen dependency) and stable u1=$(VANLINK_CONF=hosts/van.conf ./deploy.sh render ap/cellular.nmconnection | grep '^uuid=')