How can I run a script on a Mac before Airport starts?
I wrote a small shell script to spoof my wireless interface mac address. I'd like to run this script on my mac (snow leopard) before the airport utility starts and attempts to connect to an access point. Where would I put this script or what appropriate startup file is referenced where I can have it call my spoofing script?
Here's my little bash script:
$ cat spoof_apple_mac_wifi_mac.sh
#!/bin/bash
#bring en1 down
sudo ifconfig en1 down;
#generate random mac address
MAC=`/usr/bin/openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`;
#change mac address with ifconfig
sudo ifconfig en1 ether $MAC;
#bring en1 up
sudo ifconfig en1 up;
how about run a script on shutdown to turn the airport off. Then when you start up the system again airport will be off and just turn the airport on at the end of the script?
/usr/sbin/networksetup -setairportpower en1 off