fff-network: wrap CPUPORT into a function

Submitted by Adrian Schmutzler on Sept. 19, 2020, 12:01 a.m.

Details

Message ID 20200919000139.29312-1-freifunk@adrianschmutzler.de
State Superseded
Headers show

Commit Message

Adrian Schmutzler Sept. 19, 2020, 12:01 a.m.
Instead of exposing the CPUPORT variable to the calling script
directly, wrap it into a function which can be called there.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
 src/packages/fff/fff-gateway/Makefile         |  2 +-
 .../fff-gateway/files/etc/gateway.d/20-vlan   |  2 +-
 src/packages/fff/fff-network/Makefile         |  2 +-
 .../files/lib/functions/fff/cpuport           | 70 ++++++++++---------
 4 files changed, 40 insertions(+), 36 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-gateway/Makefile b/src/packages/fff/fff-gateway/Makefile
index 6a9afd03..a852cff9 100644
--- a/src/packages/fff/fff-gateway/Makefile
+++ b/src/packages/fff/fff-gateway/Makefile
@@ -1,7 +1,7 @@ 
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=fff-gateway
-PKG_RELEASE:=6
+PKG_RELEASE:=7
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/fff-gateway
 
diff --git a/src/packages/fff/fff-gateway/files/etc/gateway.d/20-vlan b/src/packages/fff/fff-gateway/files/etc/gateway.d/20-vlan
index a46bcd59..2ace14f1 100644
--- a/src/packages/fff/fff-gateway/files/etc/gateway.d/20-vlan
+++ b/src/packages/fff/fff-gateway/files/etc/gateway.d/20-vlan
@@ -16,7 +16,7 @@  configure() {
 		uci set network.$name='switch_vlan'
 		uci set network.$name.device="$(uci get network.$SWITCHDEV.name)"
 		uci set network.$name.vlan="$vlan"
-		uci set network.$name.ports="$CPUPORT $ports"
+		uci set network.$name.ports="$(get_cpu_port) $ports"
 	}
 
 	remove_vlan() {
diff --git a/src/packages/fff/fff-network/Makefile b/src/packages/fff/fff-network/Makefile
index e1b603b5..b2b8609d 100644
--- a/src/packages/fff/fff-network/Makefile
+++ b/src/packages/fff/fff-network/Makefile
@@ -1,7 +1,7 @@ 
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=fff-network
-PKG_RELEASE:=24
+PKG_RELEASE:=25
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
 
diff --git a/src/packages/fff/fff-network/files/lib/functions/fff/cpuport b/src/packages/fff/fff-network/files/lib/functions/fff/cpuport
index 27558a85..83e3731e 100644
--- a/src/packages/fff/fff-network/files/lib/functions/fff/cpuport
+++ b/src/packages/fff/fff-network/files/lib/functions/fff/cpuport
@@ -1,37 +1,41 @@ 
 # Copyright 2019 Adrian Schmutzler
 # License GPLv3
 
-BOARD="$(uci get board.model.name)"
+get_cpu_port() {
+	BOARD="$(uci get board.model.name)"
 
-case "$BOARD" in
-	tplink,tl-wr1043nd-v1)
-		CPUPORT="5t"
-		;;
-	tplink,c50-v3|\
-	tplink,tl-wr1043nd-v2|\
-	tplink,tl-wr1043nd-v3|\
-	tl-wr841n-v13|\
-	r6220|\
-	ubnt-erx|\
-	ubnt-erx-sfp)
-		CPUPORT="6t"
-		;;
-	tplink,cpe210-v2|\
-	tplink,cpe210-v3|\
-	tplink,tl-mr3020-v1|\
-	tplink,tl-wa850re-v1|\
-	tplink,tl-wa860re-v1|\
-	tplink,tl-wa901nd-v2|\
-	ubnt,bullet-m|\
-	ubnt,nanostation-loco-m|\
-	ubnt,nanostation-loco-m-xw|\
-	ubnt,nanostation-m|\
-	ubnt,picostation-m|\
-	ubnt,unifi|\
-	ubnt,unifiac-mesh)
-		CPUPORT=""
-		;;
-	*)
-		CPUPORT="0t"
-		;;
-esac
+	case "$BOARD" in
+		tplink,c50-v3|\
+		tplink,tl-wr1043nd-v2|\
+		tplink,tl-wr1043nd-v3|\
+		tl-wr841n-v13|\
+		r6220|\
+		ubnt-erx|\
+		ubnt-erx-sfp)
+			CPUPORT="6t"
+			;;
+		tplink,cpe210-v2|\
+		tplink,cpe210-v3|\
+		tplink,tl-mr3020-v1|\
+		tplink,tl-wa850re-v1|\
+		tplink,tl-wa860re-v1|\
+		tplink,tl-wa901nd-v2|\
+		ubnt,bullet-m|\
+		ubnt,nanostation-loco-m|\
+		ubnt,nanostation-loco-m-xw|\
+		ubnt,nanostation-m|\
+		ubnt,picostation-m|\
+		ubnt,unifi|\
+		ubnt,unifiac-mesh)
+			CPUPORT=""
+			;;
+		tplink,tl-wr1043nd-v1)
+			CPUPORT="5t"
+			;;
+		*)
+			CPUPORT="0t"
+			;;
+	esac
+
+	echo "$CPUPORT"
+}