Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automount network drives via ssid name
set SSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk '/ SSID: / {print $2}'"
if SSID is "officenetwork" then
tell application "Finder"
try
mount volume "afp://server.local/share1"
mount volume "afp://anotherserver.local/share2"
end try
end tell
set endresult to "Office"
else if SSID is "homenetwork" then
tell application "Finder"
try
mount volume "afp://icanhazfilez.local/share"
end try
end tell
set endresult to "Home"
else
set endresult to "fail"
end if
tell application "Growl"
set the allNotificationsList to ¬
{"Office", "Home", "Fail"}
set the enabledNotificationsList to ¬
{"Office", "Home", "Fail"}
register as application ¬
"Mount Elements" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
if endresult = "Office" then
notify with name ¬
"Office" title ¬
"Office" description ¬
"Drives mount successful" application name ¬
"Mount Elements" icon of application "AirPort Utility.app"
else if endresult = "Home" then
notify with name ¬
"Home" title ¬
"Home" description ¬
"Drives mount successful" application name ¬
"Mount Elements" icon of application "AirPort Utility.app"
else if endresult = "fail" then
notify with name ¬
"Fail" title ¬
"Home/Office Network Not Detected" description ¬
"Unable to mount network drive" application name ¬
"Mount Elements" icon of application "AirPort Utility.app"
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment