summaryrefslogtreecommitdiffstats
path: root/target/linux/oxnas/base-files/etc/board.d/02_network
blob: 747034c3ddbf89d80dad1a2d1faa8eb0d54b18d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh

bootloader_cmdline_var() {
	local param
	local pval
	for arg in $(cat /proc/device-tree/chosen/bootloader-args); do
		param="$(echo $arg | cut -d'=' -f 1)"
		pval="$(echo $arg | cut -d'=' -f 2-)"

		if [ "$param" = "$1" ]; then
			echo "$pval"
		fi
	done
}

legacy_boot_mac_adr() {
	local macstr
	local oIFS
	macstr="$(bootloader_cmdline_var mac_adr)"
	oIFS="$IFS"
	IFS=","
	set -- $macstr
	printf "%02x:%02x:%02x:%02x:%02x:%02x" $1 $2 $3 $4 $5 $6
	IFS="$oIFS"
}

oxnas_setup_interfaces()
{
	local board="$1"

	case $board in
	*)
		ucidef_set_interface_lan "eth0" "dhcp"
		;;
	esac
}

oxnas_setup_macs()
{
	local board="$1"
	local lan_mac=""

	case $board in
	shuttle,kd20)
		lan_mac="$(legacy_boot_mac_adr)"
		;;
	esac

	[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
}

board_config_update
board=$(board_name)
oxnas_setup_interfaces $board
oxnas_setup_macs $board
board_config_flush

exit 0