oxnas: switch to generic board detect
[openwrt/staging/rmilecki.git] / target / linux / oxnas / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions/uci-defaults.sh
4 . /lib/functions/system.sh
5
6 board_config_update
7
8 lan_mac=""
9
10 bootloader_cmdline_var() {
11 local param
12 local pval
13 for arg in $(cat /proc/device-tree/chosen/bootloader-args); do
14 param="$(echo $arg | cut -d'=' -f 1)"
15 pval="$(echo $arg | cut -d'=' -f 2-)"
16
17 if [ "$param" = "$1" ]; then
18 echo "$pval"
19 fi
20 done
21 }
22
23 legacy_boot_mac_adr() {
24 local macstr
25 local oIFS
26 macstr="$(bootloader_cmdline_var mac_adr)"
27 oIFS="$IFS"
28 IFS=","
29 set -- $macstr
30 printf "%02x:%02x:%02x:%02x:%02x:%02x" $1 $2 $3 $4 $5 $6
31 IFS="$oIFS"
32 }
33
34 case "$(board_name)" in
35 "shuttle,kd20")
36 lan_mac="$(legacy_boot_mac_adr)"
37 ;;
38 esac
39
40 ucidef_set_interface_lan "eth0" "dhcp"
41 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" "$lan_mac"
42
43 board_config_flush
44
45 exit 0