mirror of
https://github.com/openwrt/packages.git
synced 2026-04-15 10:51:55 +00:00
bsbf-autoconf-dhcp: switch to wan_$DEVICENAME naming scheme
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 <chester.a.unal@arinc9.com>
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user