Skip to content
Snippets Groups Projects
09-set-label-mac 717 B
Newer Older
  • Learn to ignore specific revisions
  • . /lib/functions/system.sh
    . /lib/functions/uci-defaults.sh
    . /lib/functions/iopsys-environment.sh
    
    # Ideally, we should use OpenWrt label-mac-device alias in device tree
    # but for some platforms with legacy drivers this has not been implemented.
    # For those platforms, use iopsys-environment.sh
    
    set_label_macaddr() {
    	local macaddr
    	# Use iopsys-environment (fw_printenv usually)
    	macaddr="$(macaddr_canonicalize "$(get_base_macaddr)")"
    	[ -n "$macaddr" ] || return
    	ucidef_set_label_macaddr "$macaddr"
    }
    
    mac_addr="$(get_mac_label)"
    if [ -n "$mac_addr" ]; then
    	# do not write MAC to board.json if OpenWrt get_mac_label already has one
    	exit 0
    fi
    board_config_update
    set_label_macaddr || exit 0
    board_config_flush