Skip to content

Instantly share code, notes, and snippets.

@d4kine
Created May 1, 2026 06:38
Show Gist options
  • Select an option

  • Save d4kine/a636792bceca6b56cf7b7bce26f0ccba to your computer and use it in GitHub Desktop.

Select an option

Save d4kine/a636792bceca6b56cf7b7bce26f0ccba to your computer and use it in GitHub Desktop.
MacOSX auto-mount network-shares after hibernate
set server to "[HOSTNAME]"
set mounts to {"/Volumes/[SHARE]"}
set serverReachable to (do shell script "ping -c 1 -t 1 " & server & " | grep '1 packets received' | wc -l") as integer
(* DEBUG
repeat with mountPath in mounts
do shell script "echo 'mountPath: " & server & "/" & (text 10 thru -1 of mountPath) & "'"
end repeat
*)
if serverReachable is equal to 1 then
tell application "Finder"
repeat with mountPath in mounts
if not (exists POSIX file mountPath) then
try
mount volume "smb://" & server & "/" & (text 10 thru -1 of mountPath)
end try
end if
end repeat
end tell
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment