qoriq: 02_network fix sweth globbing logic
[openwrt/staging/pepe2k.git] / target / linux / qoriq / base-files / etc / board.d / 02_network
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 . /lib/functions/uci-defaults.sh
4 . /lib/functions.sh
5 . /lib/functions/system.sh
6
7 board_config_update
8 board=$(board_name)
9
10 wg_set_opt_interface() {
11 local device="$1"
12 local offset="$2"
13
14 ucidef_set_interface "$device" device "$device" protocol static ipaddr "10.0.${offset}.1" netmask 255.255.255.0
15 }
16
17 case "$board" in
18 watchguard,firebox-m300)
19 ucidef_set_interfaces_lan_wan "eth1" "eth0"
20 wg_set_opt_interface "eth2" "2"
21
22 sweth_mac_offset=0x186d
23
24 for sweth in $(find /sys/class/net/ -name 'sweth*' -print); do
25 device="$(basename "$sweth")"
26 mac="$(mtd_get_mac_text wg_cfg0 "$sweth_mac_offset")"
27 switchports="$switchports $device"
28 ucidef_set_network_device_mac "$device" "$mac"
29 wg_set_opt_interface "$device" "${device#sweth}"
30 sweth_mac_offset=$(printf "0x%X\n" $(( $sweth_mac_offset + 0x14)))
31 done
32
33 ;;
34 esac
35
36 board_config_flush
37
38 exit 0