[PATCH] gateway.d: Add script to set wan vlan/interface
Fabian Bläse
fabian at blaese.de
So Aug 2 19:55:01 CEST 2020
Allow setting WAN vlan/interface from gateway config.
A configuration without explicit definition of a WAN interface is
valid at the moment and results in the default vlan (2) being used.
To maintain this behaviour this script sets the gateway config to vlan
2 if no vlan/interface is for WAN specified. This behaviour is transitional and
will be removed in the future.
Fixes: #143
Signed-off-by: Fabian Bläse <fabian at blaese.de>
---
.../files/etc/gateway.d/30-network-wan | 35 +++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 src/packages/fff/fff-gateway/files/etc/gateway.d/30-network-wan
diff --git a/src/packages/fff/fff-gateway/files/etc/gateway.d/30-network-wan b/src/packages/fff/fff-gateway/files/etc/gateway.d/30-network-wan
new file mode 100644
index 0000000..aea0055
--- /dev/null
+++ b/src/packages/fff/fff-gateway/files/etc/gateway.d/30-network-wan
@@ -0,0 +1,35 @@
+# load board specific properties
+BOARD="$(uci get board.model.name)"
+. /etc/network.$BOARD
+
+
+configure() {
+ # set wan interface
+ if vlan=$(uci -q get gateway. at wan[0].vlan); then
+ uci set network.wan.ifname="${SWITCHDEV}.$vlan"
+ elif iface=$(uci -q get gateway. at wan[0].iface); then
+ uci set network.wan.ifname="$iface"
+ else
+ # transitional behaviour to migrate configurations without
+ # explicit WAN vlan/interface specification
+
+ echo "WARNING: No interface for WAN specified. Setting WAN to vlan 2."
+
+ if ! uci -q get gateway. at wan[0]; then
+ uci add gateway wan >/dev/null
+ fi
+ uci set gateway. at wan[0].vlan='2'
+
+ uci set network.wan.ifname="${SWITCHDEV}.2"
+ fi
+}
+
+apply() {
+ uci commit network
+ uci commit gateway
+}
+
+revert() {
+ uci revert network
+ uci revert gateway
+}
--
2.28.0
Mehr Informationen über die Mailingliste franken-dev