Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Handy script for mounting a network share
- -- v1.0 2017-01-17, <j.glatz@supseven.at>
- -- v1.1.0 2017-01-17, <j.glatz@supseven.at>
- set shareName to "Projekte" -- assign share name
- set nasIp to "10.0.0.2" -- assign IP of NAS/server
- set pingCount to 1
- set pingTimeout to 10
- tell application "Finder"
- if not (disk shareName exists) then
- -- mount seems not to be exists
- try
- -- ping nas (max N count but max N seconds)
- do shell script "ping -c " & pingCount & " -t " & pingTimeout & " " & nasIp
- on error
- -- server doesn't respond. seems like you're not in the office or not connected to office vpn
- display dialog "😑 Sorry, das Sup7even NAS (" & nasIp & ") ist nicht erreichbar. Überprüfe dein Netzwerk! Bist du bereits mit dem VPN verbunden? Bist du im korrekten WLAN?" buttons {"😖 OK, Ich werde es überprüfen"} with icon stop giving up after 20
- -- stop execution at this point
- return
- end try
- try
- -- the nas seems to be reachable, so let's try to mount cifs/smb share
- mount volume "smb://" & nasIp & "/" & shareName
- repeat until name of every disk contains shareName
- delay 1
- end repeat
- if (disk shareName exists) then
- tell application "Finder"
- activate
- open ("/Volumes/" & shareName & "" as POSIX file)
- end tell
- end if
- end try
- else
- -- ask user if the share should be opened in Finder app
- display alert "Der Share \"" & shareName & "\" scheint bereits gemountet zu sein!" message "Du solltest noch Zugriff haben sofern du noch im Office Netzwerk bist oder mit dem Office VPN verbunden bist." buttons {"OK", "" & shareName & " Ordner öffnen"} giving up after 20
- if button returned of result = "OK" then
- -- stop execution at this point
- return
- else
- if button returned of result = "" & shareName & " Ordner öffnen" then
- do shell script "open /Volumes/" & shareName & "/"
- tell application "Finder"
- activate
- open ("/Volumes/" & shareName & "" as POSIX file)
- end tell
- end if
- end if
- end if
- end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement