User Tools

Site Tools


tutorials:airport

This is an old revision of the document!


Airport Helper

Apple’s airport devices are great routers and wifi access points that don’t so far suffer from the number of hacks and problems that other models seem to. One of the ways they get some of that extra security is by not having a web based interface, you have to run their custom application which makes a secure connection to the device to change it’s configuration.

The downside to that is that you could script talking to the web pages of other devices to get your IP address or to do a restart, you can’t do this to an airport.

The AirPort Utility is likewise not scriptable in any reasonable way, nor do they support any other communications methods such an SNMP or anything else. It turns out that the AirPort utility is scriptable through the User Interface Scripting system in OSX. I need to be able to give my airports a regular restart to keep things from getting weird or to force them to restart when the network stops working for whatever reason. I would like to automate this process so undertook to figure out the UI scripting to talk to them. It’s not at all straightforward but it turns out you actually can automate both the reading of the status of your airport units, the connection to the internet, the internet IP address and also restart an airport under scripting control.

Integration with XTension

Limitations in the user interface scripting or possibly bugs in it’s implementation in the AirPort Utility make it impractical to control it directly from a script running inside XTension. So this script is an external script saved as an Application. It will stay running on your machine as long as you wish and will query the AirPort utility every 10 seconds for changes in the status of the connection to the internet, the status of any connected airport and your internet IP address.

The script has lists of both the names of your airports and the names of pseudo units in XTension that you wish to keep in sync with their status. Create a non dimmable pseudo for each airport that you wish to scan and another for the state of the internet. The IP address that the airport thinks it’s getting from the internet will be saved to the description field of the internet state unit. You can add an on descriptionChanged event in that units On script to catch changes to the IP address and send yourself an email or anything else if you wish.

The names of those units must be filled into the proper places in the script.

Scripting a Restart

Scripting a restart of any of your airports from XTension can be done from a global script something like this

tell app “airport helper” to restartAirportByName( “Office”)

Download

AirPort helper is offered for free to XTension users and completely open and free so that others might gain from it as well. The restart function could easily be pulled into your own scripts if you are not an XTension user. It is also free from warranties or expectations that it will work for you or that it won’t do anything horrible to your own system.

At this moment I know this script will run on OSX version 10.13.4 and with AirPort Utility version 6.3.8. It may run with older or newer versions though there may be problems getting the IP address on earlier OS versions. It will run against almost any XTension version in history as it doesn’t use any new features at all.

Download: Airport Helper v1.0 (20k) 5/29/2018
MD5 Hash of the zipfile: 908a0485306cac15654270e90fe8cd95

Configuration

The script has complete instructions in it’s initial comments for setting up the system with XTension. You must create the pseudos to hold your airport device status and create any other scripts needed to call the restartAirportByName( name) handler. Additionally the fact that it uses interface scripting means that you must also enable that for the application.

  • Open the script in the script editor on the machine where it will live
  • make the changes to the script necessary to work with your airport networks and XTension
  • choose “export” from the file menu and export the script as an Application
    • choose the “stay open after run handler” option as you want this script to continue to run after it’s launched and keep scanning
  • Open the system preferences, go to the “Security & Privacy” pane. And there visit the “Privacy” tab.
  • select “Accessibility from the left hand list.
  • If necessary “click the lock to make changes” and enter your admin password.
  • drag the application you just exported into the list of apps allowed to control your computer and make sure that the checkbox left of it is checked.
  • If you make changes to the script and have to re-export you will have to revisit that control panel. It seems to be enough to un-check and re-check the app. If you do not do this it will silently fail to be able to talk to the AirPort Utility and will just tell you all your interfaces are down.
  • Launch the app. The AirPort Utility will launch and 30 seconds later it will begin scanning. You’ll get an update for the status of all your airports in XTension and the internet IP address will be added to the description of the internet status unit.
  • if you wish create scripts in XTension that call the restart for your airports or send alerts to you if things go offline or your IP changes.

Limitations of the External IP Address Field

Apple does not make it easy to get any of this information out of the application. The WAN IP address is particularly susceptible to getting lost if there are changes to the popover window that displays the data. If you have a firmware update available it may not work or if other things are different there. If you have to temporarily just disable the ip address check by entering a blank name in the script then that will get you past the problem until I find a better way to collect that information.

History

  • version 1.0 released 5/29/2018
tutorials/airport.1527621289.txt.gz · Last modified: 2023/02/13 14:51 (external edit)