If the label MAC address is provided for a device, the default SSID will be set to contain the EUI of this address, e.g. OpenWrt-ddeeff.
With multiple routers, this will help the user to identify his device based on the MAC address printed on the device. If no label MAC address is specified, this will use "OpenWrt" as done before. Using a uci-defaults script for this is necessary as mac80211.sh is executed before /etc/board.json is created, so label MAC addresses set in 02_network would not be available there. Suggested-by: Rosy Song <rosys...@rosinson.com> Signed-off-by: Adrian Schmutzler <freif...@adrianschmutzler.de> --- This effectively uses a workaround to prevent SSID from being reset after upgrade (match SSID vs. "OpenWrt"). If there is a nicer option, please propose it. Another option for this would be to explicitly mark the wireless uci config as 'default setup' by a to-be-introduced option, which is to be removed in a late uci-defaults script. This could then be exploited for several other objectives, e.g. further config-dependent WiFi setup tasks. --- .../etc/uci-defaults/15_wifi-ssid-mac-address | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 package/base-files/files/etc/uci-defaults/15_wifi-ssid-mac-address diff --git a/package/base-files/files/etc/uci-defaults/15_wifi-ssid-mac-address b/package/base-files/files/etc/uci-defaults/15_wifi-ssid-mac-address new file mode 100644 index 0000000000..aeb46e39c0 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/15_wifi-ssid-mac-address @@ -0,0 +1,22 @@ +. /lib/functions.sh +. /lib/functions/system.sh + +set_wifi_ssid() { + local iface="$1" + + [ "$(uci get "wireless.${iface}.ssid")" = "OpenWrt" ] && \ + uci set "wireless.${iface}.ssid=$ssid" +} + +label_macaddr=$(get_mac_label) + +[ -n "$label_macaddr" ] || exit 0 + +ssid="OpenWrt-$(macaddr_geteui $label_macaddr)" + +config_load wireless +config_foreach set_wifi_ssid wifi-iface + +uci commit wireless + +exit 0 -- 2.20.1 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel