#!/bin/sh

. /lib/functions.sh
. /usr/share/libubox/jshn.sh

update_mac() {
	config_get name "$1" name ""
	config_get type "$1" type ""
	config_get macaddr "$1" macaddr ""

	[ "$name" = "$br_name" ] && [ "$type" = "bridge" ] || return

	[ -z "$macaddr" ] && uci_set "network" "$1" "macaddr" "$br_mac" 
}
json_init
json_load_file "/etc/board.json"

json_select bridge
json_get_var br_name name
json_get_var br_mac macaddr

config_load network
config_foreach update_mac device
uci_commit network
