#!/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 5

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

# Notification-Center integration
notify='/bin/terminal-notifier.app/Contents/MacOS/terminal-notifier'

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

case $SSID in 
	
	# Home network SSID
	’Nic‘ )
	# do whatever you want to do. I am mounting network drives
	$notify -message "Mediathek wird verbunden ...“ -title "Im Heimnetzwerk“ -sender com.apple.Terminal	#change the path to your applescripts
	osascript ~/AppleScripts/mountMediathek.scpt
	$notify -message "Mediathek verbunden“ -title "Im Heimnetzwerk“ -sender com.apple.Terminal
	
	;;

	# Network 2
	'Firma’ )
	# do whatever you want to do.
	$notify -message "Daten wird verbunden ...“ -title "Im Firmennetzwerk“ -sender com.apple.Terminal
	osascript ~/AppleScripts/mountDaten.scpt
	$notify -message "Daten verbunden“ -title "Im Firmennetzwerk“ -sender com.apple.Terminal
	;;

	# any unspecified network
	* )
	$notify -message "Keine Aktion“ -title "Unbekanntes Netzwerk“ -sender com.apple.Terminal
	# do whatever you want

esac

exit 0