Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use sleepwatcher to manage sleep and shared volumes Network
I pretty much always have my home file server mounted via samba (automount/dynamic) on my laptop. The problem is that samba and other network shares usually don't play nice after a sleep, causing me to manually remount the shares. This is especially the case when my ip changes. My solution is to use the sleepwatcher daemon (download) to run commands just before sleep and after wake.

By unmounting your network shares just before sleep, your system won't have to deal with lost connections when it wakes up. Additionally, when your system wakes up, the sleepwatcher daemon will run your wakeup script, which can remount your network shares. sleepwatcher daemon Here are the steps:
  1. Install sleepwatcher.

  2. Make a shell script in your home directory named .sleep. I just unmount my network mounts in this script. Make sure you chmod it to at least 700; 755 is OK, too. Here's the script:
    logger -t sleepwatcher "unmounting serv"
    umount /Network/Servers/servh/data
  3. Make a shell script in your home directory named .wakup. Since this script might run before the network comes back up, I use a trick to pipe the command to a backgrounded bash prompt with a sleep 10 command. chmod this one to 700 or 755 as well:
    echo 'sleep 10
    logger -t sleepwatcher "remounting serv"
    ls /Network/Servers/servh/data' | /bin/sh&
The logger lines help you see what's going in system.log. Since my mount is dynamic, a simple ls is enough to tell automount to mount it.
    •    
  • Currently 2.33 / 5
  You rated: 2 / 5 (3 votes cast)
 
[17,823 views]  

Use sleepwatcher to manage sleep and shared volumes | 4 comments | Create New Account
Click here to return to the 'Use sleepwatcher to manage sleep and shared volumes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use sleepwatcher to manage sleep and shared volumes
Authored by: hamarkus on Jun 08, '06 10:00:41AM

Does the second script fail gracefully if it cannot find the shares?

Ideally, it would only try to reconnect if it somehow confirmed that it was still on the same network (e.g. when the IP is the same or the MAC address of the DHCP server is the same).

Even more ideally, this should be build into the OS. However, failing gracefully is very important then. I remember the old days of OS 9 (or 8?) when waking the computer would be followed by a several minute-long almost freeze-like wait until the Finder gave up on reconnecting to a previously connected server.



[ Reply to This | # ]
Use sleepwatcher to manage sleep and shared volumes
Authored by: jasonf on Jun 08, '06 03:59:50PM

I just got my first Mac yesterday morning and have been trying to figure out how to automount windows shares. I was wondering if you could tell me how you set yours up, or point me to a good tutorial.

Thanks



[ Reply to This | # ]
Some kind of solution
Authored by: hamarkus on Jun 09, '06 10:10:26AM

Mount the server in question via the Connect to Server method (cmd-K in the Finder).
Put the mounted share or any folder on it into your Finder Sidebar.
The next time you want to access a folder or file on the server, just click on what you put in the Sidebar.
This way the Server is almost like just another folder on your harddrive.



[ Reply to This | # ]
Use sleepwatcher to manage sleep and shared volumes
Authored by: diskgrinder on Jun 16, '06 01:54:06AM
I'm going to use this to show a fullscreen animation of my computer cleaning its teeth, winding up an alarm clock and switching the light out - that's a sports racer thing to do (or binary dork?)

---
I am largely flat

[ Reply to This | # ]