base-files: failsafe: Fix IP configuration
authorHauke Mehrtens <hauke@hauke-m.de>
Mon, 21 Jun 2021 22:45:19 +0000 (00:45 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Tue, 22 Jun 2021 21:23:00 +0000 (23:23 +0200)
Adapt the preinit_config_board() to the board.json network changes. It
now looks for the device and the ports variables to configure the LAN
network.

This works with swconfig configurations.

Fixes: FS#3866
Fixes: d42640e389a8 ("base-files: use "ports" array in board.json network for bridges")
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Reviewed-by: Rafał Miłecki <rafal@milecki.pl>
package/base-files/files/lib/preinit/10_indicate_preinit

index 3c59929790168c12d1745c395f171b08b6d06f8a..56e96c63baabc0c320da9b3db3d4c5c916d6bb97 100644 (file)
@@ -72,14 +72,20 @@ preinit_config_board() {
 
        json_select network
                json_select "lan"
-                       json_get_vars ifname
+                       json_get_vars device
+                       json_get_values ports ports
                json_select ..
        json_select ..
 
-       [ -n "$ifname" ] || return
+       [ -n "$device" -o -n "$ports" ] || return
+
+       # swconfig uses $device and DSA uses ports
+       [ -z "$ports" ] && {
+               ports="$device"
+       }
 
        # only use the first one
-       ifname=${ifname%% *}
+       ifname=${ports%% *}
 
        if [ -x /sbin/swconfig ]; then
                # configure the switch, if present