A "KISS" wifi manager script to push /etc/config/wireless using a central mgmt server

Hi,

I've made a keep it simple and stupid bash script to generate the /etc/config/wireless config files for multiple access points in a business environment and help to push this change out to the devices automatically.

Benefits using the script:

  • A git documentation compatible, granular set of files containing radio and wifi-iface definition for every single radio and WiFi SSID you have to provide in your environment.
  • "Auto-upload" of the generated wireless config files to the devices - or "dry" run mode
  • If you need, for example, to change a PSK on a SSID provided by 5 APs you just edit the wifi-iface/[name_of_ssid] template in one place on your mgmt server and then push changes to all APs by executing
  • "Turn off SSIDs temporarily at night" via cron supported, see example further down.
  • "HA integration" supported, the script can be called from FHEM, iobroker or whatever with the disable-ssid|enable-ssid [SSID] parameters to turn service/guest WiFi on/off on-demand.
# Only generate config files, look with git diff at them if everything is like you want it.
sh /srv/wifimgr/wifimgr.sh dry
#
# Generate and apply the new config to all of your APs
sh /srv/wifimgr/wifimgr.sh

To adjust and use the script according to your needs, you need to do the following simple, quick steps:

I'll later take time to document advanced features. The script can also do cool things like "If you generate config for AP with name 'upstairs', then leave out 'list maclist 'xxxxx''.

You can also use this script from a scheduled cron job on your mgmt server. I personally use it for turning some WiFi SSIDs off at night when I don't need them. In this case, you'd use the "option disable 'x'" instead of setting '1' or '0' explicitly and then call the script like this from "/etc/cron.d/":

# Turn night mode on - disable 'x' marked SSIDs "at night"
sh /srv/wifimgr/wifimgr.sh night
#
# Turn night mode off - Re-enable 'x' marked SSIDs "in the morning"
sh /srv/wifimgr/wifimgr.sh

Example for CLI usage to just turn off/on a certain SSID from the whole set:

sh /srv/wifimgr/wifimgr.sh disable-ssid maintenance-wifi
sh /srv/wifimgr/wifimgr.sh enable-ssid maintenance-wifi

Demo how it looks like to run this script and auto-upload generated config to 5 devices:

root@VM-MGMT:~# sh openwrt/wifimgr.sh
[WARN] Wrong shell environment, trying to restart using BASH
2021-07-02 [16-43-02] [INFO] [192.168.1.201] 'ap-01': Generating config
2021-07-02 [16-43-02] [INFO] [192.168.1.201] 'ap-01' Applying template '10-tplink-archer-c7v5-radio0' (radio0)
2021-07-02 [16-43-02] [INFO] [192.168.1.201] 'ap-01' Applying template '20-tplink-archer-c7v5-radio1' (radio1)
2021-07-02 [16-43-02] [INFO] [192.168.1.201] 'ap-01' Applying template '10-mesh' (MESH)
2021-07-02 [16-43-02] [INFO] [192.168.1.201] 'ap-01' Applying template '20-wifi-office' (wifi)
2021-07-02 [16-43-02] [INFO] [192.168.1.201] 'ap-01' Applying template '30-wifi-special' (wifi-special)
2021-07-02 [16-43-02] [INFO] [192.168.1.201] 'ap-01' Applying template '40-wifi-it' (wifi-IT)
2021-07-02 [16-43-02] [INFO] [192.168.1.201] 'ap-01' Applying template '50-chromecast' (CHROMECAST)
2021-07-02 [16-43-02] [INFO] [192.168.1.201] 'ap-01' Applying template '60-wifi-guest' (wifi-guest)
2021-07-02 [16-43-02] [INFO] [192.168.1.201] 'ap-01' Applying template '70-wifi-mdm' (wifi-MDM)
2021-07-02 [16-43-02] [INFO] [192.168.1.201] 'ap-01' Merged 9 WiFi interfaces
2021-07-02 [16-43-02] [INFO] [192.168.1.201] 'ap-01': Config upload ...
2021-07-02 [16-43-03] [INFO] [192.168.1.201] 'ap-01': Config commit in 45s ...
2021-07-02 [16-43-03] [INFO] [192.168.1.202] 'ap-02': Generating config
2021-07-02 [16-43-03] [INFO] [192.168.1.202] 'ap-02' Applying template '10-tplink-archer-c7v5-radio0' (radio0)
2021-07-02 [16-43-03] [INFO] [192.168.1.202] 'ap-02' Applying template '20-tplink-archer-c7v5-radio1' (radio1)
2021-07-02 [16-43-03] [INFO] [192.168.1.202] 'ap-02' Skipping template '10-mesh', reason: generic use case restriction
2021-07-02 [16-43-03] [INFO] [192.168.1.202] 'ap-02' Applying template '20-wifi-office' (wifi)
2021-07-02 [16-43-03] [INFO] [192.168.1.202] 'ap-02' Applying template '30-wifi-special' (wifi-special)
2021-07-02 [16-43-03] [INFO] [192.168.1.202] 'ap-02' Applying template '40-wifi-it' (wifi-IT)
2021-07-02 [16-43-03] [INFO] [192.168.1.202] 'ap-02' Applying template '50-chromecast' (CHROMECAST)
2021-07-02 [16-43-03] [INFO] [192.168.1.202] 'ap-02' Applying template '60-wifi-guest' (wifi-guest)
2021-07-02 [16-43-03] [INFO] [192.168.1.202] 'ap-02' Applying template '70-wifi-mdm' (wifi-MDM)
2021-07-02 [16-43-03] [INFO] [192.168.1.202] 'ap-02' Merged 7 WiFi interfaces
2021-07-02 [16-43-03] [INFO] [192.168.1.202] 'ap-02': Config upload ...
2021-07-02 [16-43-04] [INFO] [192.168.1.202] 'ap-02': Config commit in 5s ...
2021-07-02 [16-43-04] [INFO] [192.168.1.203] 'ap-03': Generating config
2021-07-02 [16-43-04] [INFO] [192.168.1.203] 'ap-03' Applying template '10-tplink-archer-c7v5-radio0' (radio0)
2021-07-02 [16-43-04] [INFO] [192.168.1.203] 'ap-03' Applying template '20-tplink-archer-c7v5-radio1' (radio1)
2021-07-02 [16-43-04] [INFO] [192.168.1.203] 'ap-03' Skipping template '10-mesh', reason: generic use case restriction
2021-07-02 [16-43-04] [INFO] [192.168.1.203] 'ap-03' Applying template '20-wifi-office' (wifi)
2021-07-02 [16-43-04] [INFO] [192.168.1.203] 'ap-03' Applying template '30-wifi-special' (wifi-special)
2021-07-02 [16-43-04] [INFO] [192.168.1.203] 'ap-03' Applying template '40-wifi-it' (wifi-IT)
2021-07-02 [16-43-04] [INFO] [192.168.1.203] 'ap-03' Applying template '50-chromecast' (CHROMECAST)
2021-07-02 [16-43-04] [INFO] [192.168.1.203] 'ap-03' Applying template '60-wifi-guest' (wifi-guest)
2021-07-02 [16-43-04] [INFO] [192.168.1.203] 'ap-03' Applying template '70-wifi-mdm' (wifi-MDM)
2021-07-02 [16-43-04] [INFO] [192.168.1.203] 'ap-03' Merged 6 WiFi interfaces
2021-07-02 [16-43-04] [INFO] [192.168.1.203] 'ap-03': Config upload ...
2021-07-02 [16-43-05] [INFO] [192.168.1.203] 'ap-03': Config commit in 5s ...
2021-07-02 [16-43-05] [INFO] [192.168.1.204] 'ap-04': Generating config
2021-07-02 [16-43-05] [INFO] [192.168.1.204] 'ap-04' Applying template '10-tplink-archer-c7v5-radio0' (radio0)
2021-07-02 [16-43-05] [INFO] [192.168.1.204] 'ap-04' Applying template '20-tplink-archer-c7v5-radio1' (radio1)
2021-07-02 [16-43-05] [INFO] [192.168.1.204] 'ap-04' Skipping template '10-mesh', reason: generic use case restriction
2021-07-02 [16-43-05] [INFO] [192.168.1.204] 'ap-04' Applying template '20-wifi-office' (wifi)
2021-07-02 [16-43-05] [INFO] [192.168.1.204] 'ap-04' Applying template '30-wifi-special' (wifi-special)
2021-07-02 [16-43-05] [INFO] [192.168.1.204] 'ap-04' Applying template '40-wifi-it' (wifi-IT)
2021-07-02 [16-43-05] [INFO] [192.168.1.204] 'ap-04' Applying template '50-chromecast' (CHROMECAST)
2021-07-02 [16-43-05] [INFO] [192.168.1.204] 'ap-04' Applying template '60-wifi-guest' (wifi-guest)
2021-07-02 [16-43-05] [INFO] [192.168.1.204] 'ap-04' Applying template '70-wifi-mdm' (wifi-MDM)
2021-07-02 [16-43-05] [INFO] [192.168.1.204] 'ap-04' Merged 8 WiFi interfaces
2021-07-02 [16-43-05] [INFO] [192.168.1.204] 'ap-04': Config upload ...
2021-07-02 [16-43-06] [INFO] [192.168.1.204] 'ap-04': Config commit in 25s ...
2021-07-02 [16-43-06] [INFO] [192.168.1.205] 'ap-05': Generating config
2021-07-02 [16-43-06] [INFO] [192.168.1.205] 'ap-05' Applying template '10-tplink-archer-c7v5-radio0' (radio0)
2021-07-02 [16-43-06] [INFO] [192.168.1.205] 'ap-05' Applying template '20-tplink-archer-c7v5-radio1' (radio1)
2021-07-02 [16-43-06] [INFO] [192.168.1.205] 'ap-05' Applying template '10-mesh' (MESH)
2021-07-02 [16-43-06] [INFO] [192.168.1.205] 'ap-05' Applying template '20-wifi-office' (wifi)
2021-07-02 [16-43-06] [INFO] [192.168.1.205] 'ap-05' Applying template '30-wifi-special' (wifi-special)
2021-07-02 [16-43-06] [INFO] [192.168.1.205] 'ap-05' Applying template '40-wifi-it' (wifi-IT)
2021-07-02 [16-43-07] [INFO] [192.168.1.205] 'ap-05' Applying template '50-chromecast' (CHROMECAST)
2021-07-02 [16-43-07] [INFO] [192.168.1.205] 'ap-05' Applying template '60-wifi-guest' (wifi-guest)
2021-07-02 [16-43-07] [INFO] [192.168.1.205] 'ap-05' Applying template '70-wifi-mdm' (wifi-MDM)
2021-07-02 [16-43-07] [INFO] [192.168.1.205] 'ap-05' Merged 6 WiFi interfaces
2021-07-02 [16-43-07] [INFO] [192.168.1.205] 'ap-05': Config upload ...
2021-07-02 [16-43-07] [INFO] [192.168.1.205] 'ap-05': Config commit in 25s ...
2021-07-02 [16-43-10] [INFO] [192.168.1.202] 'ap-02': Config commit successful.
2021-07-02 [16-43-11] [INFO] [192.168.1.203] 'ap-03': Config commit successful.
2021-07-02 [16-43-32] [INFO] [192.168.1.204] 'ap-04': Config commit successful.
2021-07-02 [16-43-34] [INFO] [192.168.1.205] 'ap-05': Config commit successful.
2021-07-02 [16-43-50] [INFO] [192.168.1.201] 'ap-01': Config commit successful.
2021-07-02 [16-43-50] [INFO] Done.

4 Likes