RecentChanges TextFormattingRules AllWikiTopics OrphanedWikiTopics ToDoWikiTopics WikiLockList RSS Export2HTML WikiSearch SetUsername StartingPoints Home |
OSX:RunWhenNetworkChanges
How To run a script when the networking location changesCreate the script you want to run. $ vim /Users/mdsh/bin/route-add #!/bin/bash route delete 10.0.0.0/8 10.64.0.253 route add 10.0.0.0/8 10.64.0.253 Make the script runnable. $ chmod a+x /Users/mdsh/bin/route-add Create a plist which defines a script to be run upon the detection of a change in a networking file. $ sudo vim /Library/Preferences/SystemConfiguration/com.mdsh.createRoutes.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \ "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>ifup.ddns</string> <key>LowPriorityIO</key> <true/> <key>ProgramArguments</key> <array> <string>/Users/mdsh/bin/route-add-leyborne</string> </array> <key>WatchPaths</key> <array> <string>/etc/resolv.conf</string> <string>/Library/Preferences/SystemConfiguration/NetworkInterfaces.plist</string> <string>/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> Load the plist. $ sudo launchctl load /Library/Preferences/SystemConfiguration/com.mdsh.createRoutes.plist OSX:RunWhenNetworkChanges is mentioned on: OSX |