From a34c043890a4521b41869a2fb41909f02809df9f Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 15 Aug 2019 15:13:27 +0200 Subject: [PATCH] base-files: provide option to specify label MAC address in board.d For many devices, MAC addresses cannot be retrieved via the device tree alias. To still provide the label MAC address for those, this implements a second mechanism that will put the address into uci config. Note that this stores the actual MAC address, whereas in DTS we reference the bearing device. This is based on the work of Rosy Song Signed-off-by: Adrian Schmutzler --- package/base-files/files/bin/config_generate | 6 ++++++ package/base-files/files/lib/functions/system.sh | 1 + 2 files changed, 7 insertions(+) diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 91396fb75d..a72702492f 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -20,6 +20,7 @@ generate_static_network() { uci -q batch <<-EOF delete network.globals set network.globals='globals' + set network.globals.ula_prefix='auto' EOF } @@ -256,6 +257,11 @@ generate_static_system() { uci -q set "system.@system[-1].hostname=$hostname" fi + local label_macaddr + if json_get_var label_macaddr label_macaddr; then + uci -q set "system.@system[-1].label_macaddr=$label_macaddr" + fi + if json_is_a ntpserver array; then local keys key json_get_keys keys ntpserver diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index c372d37e38..6ff1c68577 100755 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -19,6 +19,7 @@ get_mac_label() { [ -n "$macdevice" ] && macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 2>/dev/null) [ -n "$macaddr" ] || macaddr=$(get_mac_binary "$basepath/$macdevice/local-mac-address" 0 2>/dev/null) + [ -n "$macaddr" ] || macaddr=$(uci -q get system.@system[0].label_macaddr) echo $macaddr }