bsbf-autoconf-dhcp: switch to wan_$DEVICENAME naming scheme
authorChester A. Unal <redacted>
Thu, 5 Mar 2026 20:17:00 +0000 (22:17 +0200)
committerChester A. Unal <redacted>
Sat, 7 Mar 2026 10:07:15 +0000 (12:07 +0200)
Use wan_$DEVICENAME naming scheme instead of using consecutive numbering
for the network name.

This makes it easier to match the network interface to the corresponding
network.

Signed-off-by: Chester A. Unal <redacted>
net/bsbf-openwrt-resources/Makefile
net/bsbf-openwrt-resources/files/etc/hotplug.d/net/99-bsbf-autoconf-dhcp

index b1b182035864181f2ec4ae0b4384da52819f6720..86b87d0a90a7b091e91bcfdf02d814d4fa8b102d 100644 (file)
@@ -4,7 +4,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=bsbf-openwrt-resources
-PKG_VERSION:=2
+PKG_VERSION:=3
 
 PKG_LICENSE:=AGPL-3.0-or-later
 PKG_MAINTAINER:=Chester A. Unal <chester.a.unal@arinc9.com>
index 2362fc2c09ee313047bbc8bda37a46ec30da16a6..4b4c27d0a2605301ff38b18ad12c07bbea600c98 100644 (file)
@@ -8,11 +8,11 @@
 # Exclude MBIM and QMI network interfaces which a DHCP client wouldn't work on.
 grep -E "(mbim|qmi)" /sys"${DEVPATH%/*/*}/uevent" && exit
 
-# Exit if a network with the network interface already exists.
-uci_network=$(uci show network)
-echo "$uci_network" | grep -q ".device='$DEVICENAME'" && exit
+# If a network with the same name already exists, exit.
+uci get network.wan_"$DEVICENAME" && exit
 
 # Decide on the metric value. Start from 1 and work up to 8.
+uci_network=$(uci show network)
 metric=1
 while [ $metric -le 8 ]; do
        # Break if this metric isn't in use.
@@ -24,16 +24,10 @@ done
 # If there are no available metrics, exit with code 1.
 [ "$metric" -gt 8 ] && exit 1
 
-# Decide on the network name. Start from wan1.
-index=1
-while echo "$uci_network" | grep -q "wan$index"; do
-       index=$((index + 1))
-done
-
-uci set network.wan$index=interface
-uci set network.wan$index.device="$DEVICENAME"
-uci set network.wan$index.proto='dhcp'
-uci set network.wan$index.peerdns='0'
-uci set network.wan$index.metric="$metric"
+uci set network.wan_"$DEVICENAME"=interface
+uci set network.wan_"$DEVICENAME".device="$DEVICENAME"
+uci set network.wan_"$DEVICENAME".proto='dhcp'
+uci set network.wan_"$DEVICENAME".peerdns='0'
+uci set network.wan_"$DEVICENAME".metric="$metric"
 uci commit network
-ifup wan$index
+ifup wan_"$DEVICENAME"
git clone https://git.99rst.org/PROJECT