aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib
diff options
context:
space:
mode:
authorJonas Gorski <jonas.gorski@gmail.com>2016-07-29 00:25:09 +0200
committerJonas Gorski <jonas.gorski@gmail.com>2016-08-13 15:50:15 +0200
commit6c9588ddf58ba1417cb92ee44d91c11bb77a7038 (patch)
tree442caed8a4c743506d8c4cef955e4f7ec98a26eb /package/base-files/files/lib
parent072cf26729aca15b8a0526f18bce2b5e7a27ab12 (diff)
downloadupstream-6c9588ddf58ba1417cb92ee44d91c11bb77a7038.tar.gz
upstream-6c9588ddf58ba1417cb92ee44d91c11bb77a7038.tar.bz2
upstream-6c9588ddf58ba1417cb92ee44d91c11bb77a7038.zip
base-files: configure switch in failsafe
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@gmail.com>
Diffstat (limited to 'package/base-files/files/lib')
-rw-r--r--package/base-files/files/lib/preinit/10_indicate_preinit48
1 files 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 33e90b1d28..82b730f0c5 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_ip_config() {
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() {
/bin/board_detect /tmp/board.json
@@ -43,8 +78,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_ip_config $ifname
}