summaryrefslogtreecommitdiffstats
path: root/target/linux/realtek/base-files/etc/uci-defaults/02_network
blob: d2d2e98297238d26c6538ffa2e9eaa0feef34201 (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
#!/bin/sh

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

realtek_setup_interfaces()
{
	local board="$1"

	ucidef_set_interface_loopback

	case $board in
	generic | \
	nprove | \
	nprove2)
		ucidef_set_interfaces_lan_wan "eth0 eth2 eth3 eth4" "eth1"
		;;

	nprove3)
		ucidef_set_interface_lan "eth0.1"
		;;

	*)
		ucidef_set_interfaces_lan_wan "eth0" "eth1"
		;;
	esac
}

realtek_setup_macs()
{
	local board="$1"
	local lan_mac=""
	local wan_mac=""

	case $board in
	generic | \
	nprove)
		lan_mac=$(rtkmib --get mac0)
		wan_mac=$(rtkmib --get mac1)
		;;
	esac

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

[ -e /etc/config/network ] && exit 0

touch /etc/config/network

board=$(realtek_board_name)

realtek_setup_interfaces $board
realtek_setup_macs $board

uci commit network

exit 0