#!/bin/bash

# automatically mount network volumes on network change

# redirect all IO to /dev/null
exec 1>/dev/null 2>/dev/null

# wait 2 seconds for connection to be established
sleep 2

# get various system information
SSID=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I\ | grep ' SSID:' | cut -d ':' -f 2 | tr -d ' '`

# SSID will not include spaces so leave them out when entering the name of your network

case $SSID in 
	
	# Home network SSID
	'Your network SSID goes here. keep the single quotes' )
	# do whatever you want to do. I am mounting network drives
	/usr/local/bin/growlnotify -m "Joined home network and mounting Airport drives..."
	#change the path to your applescripts
	osascript ~/appleScripts/mountAirportMedia.scpt
	osascript ~/appleScripts/mountAirportBackup.scpt
	/usr/local/bin/growlnotify -m "Airport drives mounted!"
	
	;;

	# Network 2
	'network2' )
	# do whatever you want to do.
	/usr/local/bin/growlnotify -m "Joined network 2. Doing Nothing."

	;;

	# any unspecified network
	* )
	/usr/local/bin/growlnotify -m "Joined unknown network. Doing nothing."
	# do whatever you want

esac

exit 0