[LEDE-DEV] [RFC/RFT 4/7] base-files: configure switch in failsafe
Jonas Gorski
jonas.gorski at gmail.com
Fri Jul 29 02:07:52 PDT 2016
Also configure the switch based on the failsafe config, and create the
failsafe interface as tagged if necessary.
Signed-off-by: Jonas Gorski <jonas.gorski at gmail.com>
---
.../files/lib/preinit/10_indicate_preinit | 48 +++++++++++++++++++++-
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit
index e9ecfb8..ee8159f 100644
--- a/package/base-files/files/lib/preinit/10_indicate_preinit
+++ b/package/base-files/files/lib/preinit/10_indicate_preinit
@@ -22,6 +22,41 @@ preinit_config_netdev() {
ip -4 address add $pi_ip/$pi_netmask broadcast $pi_broadcast dev $1
}
+preinit_config_switch() {
+ local role roles ports device enable reset
+
+ local name=$1
+ local lan_if=$2
+
+ json_select switch
+ json_select $name
+
+ json_get_vars enable reset
+
+ if json_is_a roles array; then
+ json_get_keys roles roles
+ json_select roles
+
+ for role in $roles; do
+ json_select "$role"
+ json_get_vars ports device
+ json_select ..
+
+ if [ "$device" = "$lan_if" ]; then
+ swconfig dev $name set reset $reset
+ swconfig dev $name set enable_vlan $enable
+ swconfig dev $name vlan $role set ports "$ports"
+ swconfig dev $name set apply
+ fi
+ done
+
+ json_select ..
+ fi
+
+ json_select ..
+ json_select ..
+}
+
preinit_config_board() {
[ -z "$ifname" ] || return
@@ -45,8 +80,17 @@ preinit_config_board() {
# only use the first one
ifname=${ifname%% *}
- # trim any vlan ids
- ifname=${ifname%\.*}
+ if [ -x /sbin/swconfig ]; then
+ # configure the switch, if present
+
+ json_get_keys keys switch
+ for key in $keys; do
+ preinit_config_switch $key $ifname
+ done
+ else
+ # trim any vlan ids
+ ifname=${ifname%\.*}
+ fi
preinit_config_netdev $ifname
}
--
2.1.4
More information about the Lede-dev
mailing list