STA Manager-like Scripts for Clean or LEDE Builds

This may be a duplication of efforts, but I’ve written some scripts to reproduce STAManager functionality for LEDE and OpenWRT clean builds. Assuming you’re only using UCI or LuCI for management, they do a reasonable job at it. My goal was to ensure that the AP would be available if there were no known wireless networks around, to automatically try connecting to a list of known networks when the device boots, and to avoid installing any additional pkgs. There are 3 scripts in total. Rename from .txt to .sh, and chmod 755 the two scripts that need to go in /usr/local/bin.


  • Executes when STA radio is started

  • Waits 5 seconds for a connection, then starts the wlan-scan script if no connection occurs

  • If there is a connection, starts the wlan-save script


  • Scans for available SSIDs

  • Compares the live SSIDs against a list of saved SSIDs, if there’s a match, rewrites the wireless config to use the first matching network

  • Waits for a connection, if not successful will try the next available network in the list and so on

  • If no networks are available, removes the STA radio config to allow just the AP to broadcast


  • Compares the current STA network config to the saved list of wireless networks

  • If its not already saved on the list, adds it


They’re pretty bare bones but get the job done, and pretty quickly too. I’m open to suggestions if more skilled folks think there’re better ways to accomplish this.

This functionality is probably the single biggest gap in OpenWrt and LEDE and one of the reasons I think the GLI GUI is so great.

By no means am I trying to discourage you from this pursuit, but there are a hand full of these out there including one I have made some mods to: 404 Page not found - GL.iNet and this one from Dirk Benson which I am currently testing: OpenWrt Forum Archive

Hopefully there is something you can learn from the code in these.

I will suggest you try to avoid expecting the STAtion to be either the [0] or[1] specifically. If someone uses Luci, it’s easy to wipe the entries and the STAtion can be [0]. The little check box at the top of Luci’s “Join Network” page which says “Replace Wireless Config” can mess up the works if not set correctly.

What I consider the big gap in every solution so far is the inability to add a STAtions to a library from the GUI.

Probably worth noting where the list is stored (etc\config?) and the correct format for manually adding some STAtions.


Thanks for the feedback, RangerZ.

My initial searches didn’t yield any results for something to handle that functionality, so I gave up and decided to try and deal with it myself. I certainly did take a lot of shortcuts to make something functional, and short of a nice means of managing the list of networks, it does the job. A newer iteration does check for an interface in STA mode.

Travelmate looks interesting, however.

And I agree that the station manager is the one thing that I liked about the GLi GUI.


This link has a similar script, if you are interested:

@Glitch, the particular wiki as written basically works by switching 2 sets of config files, one for a connection to an AP and another set when there is no available AP (to specifically recover from the dreaded “No WLAN access when the configured STAtion is unavailable” problem). This solution misses the other important element of the requirement, the ability to choose between multiple STAtions. All the other solutions that exist store the station data and update the wireless config file as opposed to replacing a group of files.

If you follow the link in the wiki it will take you to the basis for the first link I offered above (originally writen by dabd64, thank you!). The wiki is by a different author.

I’ve started trying to understand how travelmate works, and I see what its doing. Where my kludgy script is different is that it’ll actually scan the air, and if none of the STAtions exist, will remove the STA config completely to allow AP only to work. It will restore the STA config if one of the stored STAtions is out there at boot or at a wifi interface change. Travelmate looks like it does something similar, except it doesn’t remove the STAtion config.

There are issues associated with that, but they’re fairly minor. I think I can use travelmate as a base to get exactly what I want. Learning scripting on this is a fun little activity.

Thanks for all the suggestions, guys!

Travelmate doesn’t remove STA entries because it only enables specific STAs when they’re found in the scan. That allows you to define multiple STA (like different hotel networks) in your WiFi config and travelmate will connect to the one it finds.