diff --git a/meta-digi-dey/recipes-connectivity/hostapd/hostapd/ccimx6ul/hostapd_wlan1.conf b/meta-digi-dey/recipes-connectivity/hostapd/hostapd/ccimx6ul/hostapd_wlan1.conf index 3d2e87d0d..a5ee3b926 100644 --- a/meta-digi-dey/recipes-connectivity/hostapd/hostapd/ccimx6ul/hostapd_wlan1.conf +++ b/meta-digi-dey/recipes-connectivity/hostapd/hostapd/ccimx6ul/hostapd_wlan1.conf @@ -4,7 +4,7 @@ interface=wlan1 driver=nl80211 # WPA2-AES encryption -ssid=ap-wlan1-wpa2aes_a +ssid=ap-wlan1-##MAC## auth_algs=1 wpa=2 wpa_key_mgmt=WPA-PSK diff --git a/meta-digi-dey/recipes-connectivity/hostapd/hostapd/hostapd_wlan0.conf b/meta-digi-dey/recipes-connectivity/hostapd/hostapd/hostapd_wlan0.conf index 570643ccd..73aaa58c4 100644 --- a/meta-digi-dey/recipes-connectivity/hostapd/hostapd/hostapd_wlan0.conf +++ b/meta-digi-dey/recipes-connectivity/hostapd/hostapd/hostapd_wlan0.conf @@ -4,7 +4,7 @@ interface=wlan0 driver=nl80211 # WPA2-AES encryption -ssid=ap-wlan0-wpa2aes_a +ssid=ap-wlan0-##MAC## auth_algs=1 wpa=2 wpa_key_mgmt=WPA-PSK diff --git a/meta-digi-dey/recipes-connectivity/hostapd/hostapd_%.bbappend b/meta-digi-dey/recipes-connectivity/hostapd/hostapd_%.bbappend index 4134c7993..76f7b529a 100644 --- a/meta-digi-dey/recipes-connectivity/hostapd/hostapd_%.bbappend +++ b/meta-digi-dey/recipes-connectivity/hostapd/hostapd_%.bbappend @@ -17,5 +17,30 @@ do_install_append_ccimx6ul() { install -m 0644 ${WORKDIR}/hostapd_wlan1.conf ${D}${sysconfdir} } +pkg_postinst_${PN}() { + # Append the last two bytes of the wlan0 MAC address to the SSID of the + # hostAP configuration files + # (execute on first boot) + if [ -n "$D" ]; then + exit 1 + fi + + # Get the last two bytes of the wlan0 MAC address + MAC="$(cut -d ':' -f5,6 /sys/class/net/wlan0/address | tr -d ':')" + + # If wlan0 is not available, use a random value with no hexadecimal characters + if [ -z "${MAC}" ]; then + MAC="$(cat /dev/urandom | tr -dc 'G-Z' | fold -w 4 | head -n 1)" + fi + + find "${sysconfdir}" -type f -name 'hostapd_wlan?.conf' -exec \ + sed -i -e "s,##MAC##,${MAC},g" {} \; + + # Create the symlinks in the different runlevels + if type update-rc.d >/dev/null 2>/dev/null; then + update-rc.d ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} + fi +} + # Do not autostart hostapd daemon, it will conflict with wpa-supplicant. INITSCRIPT_PARAMS = "remove"