#!/bin/sh

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

ipq50xx_setup_interfaces()
{
	local board="$1"
	case $board in
		linksys,mx2000|\
		linksys,mx5500)
			ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
			;;
	esac
}

ipq50xx_setup_macs()
{
	local board="$1"
	local lan_mac=""
	local wan_mac=""
	local label_mac=""

	case "$board" in
		linksys,mx2000|\
		linksys,mx5500)
			label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
			lan_mac=$label_mac
			wan_mac=$label_mac
			ucidef_set_network_device_mac eth0 $label_mac
		;;
	esac

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

board_config_update
board=$(board_name)
ipq50xx_setup_interfaces $board
ipq50xx_setup_macs $board
board_config_flush

exit 0
