Run job when network configuration changes
I'm looking at the new KeepAlive section in the launchd.plist man page, specifically at the NetworkStatus item. Could this be used to run a job _once_ whenever the system's network configuration changes ... a laptop moves from wired to wireless, or moves from work to home, or the like? But run the same job each time the network config changes? I'm not quite sure from the description. I used to be able to add an item to Kicker.xml for SystemConfiguration, but I hear that's no longer an option. I haven't checked for it yet, myself, though. Even so, this was not optimal because my edits in Kicker.xml might have overwritten by Apple in a future software update. Writing my own daemon is also not an option; this is purely for systems administration purposes and I'd like to only _add_ a launchd plist and _add_ a script to the system if that's possible. This ability to only add on, not edit or replace existing config files, is one attraction of launchd at the systems administration level. Thanks! -- Jeremy
At 14:55 -0400 29/10/07, Jeremy Reichman wrote:
Could this be used to run a job _once_ whenever the system's network configuration changes ... a laptop moves from wired to wireless, or moves from work to home, or the like? But run the same job each time the network config changes? I'm not quite sure from the description.
AFAICT this won't do what you want. This option is triggered when the system transitions from zero IP interface to not zero IP interfaces, and vice versa. It is not triggered, for example, when you transition from one IP address to a different one. S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
On Mon, 29 Oct 2007 20:43:20 +0100, "Quinn" <eskimo1@apple.com> said:
At 14:55 -0400 29/10/07, Jeremy Reichman wrote:
Could this be used to run a job _once_ whenever the system's network configuration changes ... a laptop moves from wired to wireless, or moves from work to home, or the like? But run the same job each time the network config changes? I'm not quite sure from the description.
AFAICT this won't do what you want. This option is triggered when the system transitions from zero IP interface to not zero IP interfaces, and vice versa. It is not triggered, for example, when you transition from one IP address to a different one.
Is there a way to run such a job with launchd now? If Kicker.xml from SystemConfiguration is gone, as I've heard, I'd like to find an alternative. I have had at least one specific need for it in the past. It always would have been cleaner, to my way of thinking, to have launchd let me watch for network change events directly and then trigger my job. This feels like a good addition if it's not there, now that launchd can trigger a job during the transition from zero to some interfaces and vice versa. The missing piece appears to be the transition from one IP to another. If that's still not possible in launchd I'd be happy to file an enhancement request, unless there's a specific reason this type of trigger should be avoided. Thanks! -- Jeremy
participants (2)
-
Jeremy Reichman
-
Quinn