diff --git a/wifidmd/files/etc/wifidmd/bbf_config_reload.sh b/wifidmd/files/etc/wifidmd/bbf_config_reload.sh index a469f00e4..24f672dac 100755 --- a/wifidmd/files/etc/wifidmd/bbf_config_reload.sh +++ b/wifidmd/files/etc/wifidmd/bbf_config_reload.sh @@ -107,6 +107,63 @@ wait_for_wifi_reload() { return 1 } +############################################################################### +# mark_ap_instances_applied +# +# Description: +# Finalizes newly created WiFi AccessPoint instances in the dmmap WiFi +# configuration. +# +# An AccessPoint instance is considered a *new instance* when the option +# __is_new__ exists and its value is "1". +# +# New instance handling logic: +# +# • The AccessPoint's controller-side section name is obtained from +# the __section_name__ option (e.g., "mapcontroller.xxx" or "wireless.xxx"). +# +# • For new instances where __section_name__ begins with "mapcontroller.": +# - Remove __is_new__ +# - No additional actions required +# +# • For new instances where __section_name__ begins with "wireless.": +# - Set mapcontroller=0 (indicates mapcontroller reload is not required) +# - Remove __is_new__ +# +# • For all other prefixes: +# - Remove __is_new__ only +# +# After all new instances are processed, the dmmap WiFi configuration is committed. +############################################################################### +mark_ap_instances_applied() { + for sec in $(uci -q -c /etc/bbfdm/dmmap show WiFi | grep "=AccessPoint" | cut -d. -f2 | cut -d= -f1); do + is_new=$(uci -q -c /etc/bbfdm/dmmap get WiFi.${sec}.__is_new__) + + if [ "${is_new}" = "1" ]; then + config_sec_name=$(uci -q -c /etc/bbfdm/dmmap get WiFi.${sec}.__section_name__) + case "${config_sec_name}" in + mapcontroller.*) + # New mapcontroller AP instance — remove creation flag only + uci -q -c /etc/bbfdm/dmmap delete WiFi.${sec}.__is_new__ + ;; + + wireless.*) + # New wireless AP instance — skip mapcontroller reload + mapcontroller=0 + uci -q -c /etc/bbfdm/dmmap delete WiFi.${sec}.__is_new__ + ;; + + *) + # Other AP instance types — remove creation flag only + uci -q -c /etc/bbfdm/dmmap delete WiFi.${sec}.__is_new__ + ;; + esac + fi + done + + uci -q -c /etc/bbfdm/dmmap commit WiFi +} + # Define function to reload mapcontroller reload_mapcontroller() { pid=$(pidof mapcontroller) @@ -126,6 +183,9 @@ commit_wireless_config() { wait_for_wifi_reload } +# Finalize newly created AP AccessPoint instances +mark_ap_instances_applied + # Apply logic based on flags if [ "$mapcontroller" -eq 1 ]; then reload_mapcontroller