Gene, it just occurred to me (after coming across this script) that you were looking to maybe automate this? Here is some hackery to get you on your way:
There used to be built-in private hooks in the OS to react to changes in the network configuration (such as switching from Ethernet to Airport, or moving from one network to another). A simple way to get this functionality back in Snow Leopard is to monitor config files that change when the network config changes. One such file is /var/run/resolv.conf
First, build a launchd script that monitors changes of the /etc/resolv.conf file:
launchd plist (put in /Library/LaunchDaemons/)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>edu.apple.detectnetworkchanges</string> <key>ProgramArguments</key> <array> <string>/Library/Scripts/detectnetworkchange.sh</string> </array> <key>RunAtLoad</key> <true/> <key>WatchPaths</key> <array> <string>/var/run/resolv.conf</string> </array> </dict> </plist>
Sample script (Determines the IP and logs it, put in /Library/Scripts):
#!/bin/bash
# detectnetworkchange.sh # #This script will add all members from a network group #to a local group and also remove members from the local #group that are missing on the network.
PATH=/usr/bin:/bin:/usr/sbin:/sbin export PATH
#for now all we do is log the IP address: ip_address=`ifconfig -a | grep -w inet | awk 'NR == 2 {print $2}'`
echo "detectnetworkchange.sh: New IP: $ip_address"
exit 0
Then load the configuration into launchd:
sudo launchctl load edu.apple.detectnetworkchanges.plist
(or whatever you called the plist file)
Unplug and re-plug ethernet or turn Airport on and off, watch system.log and think of all the nice things you can mess up... er... achieve now.
On Feb 25, 2010, at 10:02 AM, Gene Sanchez wrote: Is anyone aware of how to disable an Airport card when the ethernet is plugged in? Would also need this to re-enable the Airport Card when ethernet was unplugged?
What's happening is that we have too many devices that take up IPs and we need a way that our laptops would not take up two ip addresses. We do not want to static assign all the laptops to with the same IP for both ethernet and airport.
Do not post admin requests to the list. They will be ignored.
Rockies-edu mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
|