Reply
   
 Solution: How to auto reconnect a network drive after resuming from sleep 
 
 
  #1 (permalink)  
Old 01-01-2008, 01:46 PM
Member

Group: Regulars
Location: Sydney


Solution: How to auto reconnect a network drive after resuming from sleep

Solution: How to auto reconnect a network drive after resuming from sleep

Hi,

You may have found that Tiger 10.4 and previous OS X versions all drop network connections when the mac goes to sleep. Here is one simple way to have OS X automatically reconnect a mounted drive (share) after resuming from sleep.

I use a iMac mini as a multimedia centre, running an ethernet network connected to a 10/100 NAS drive for storage of Movies and iTunes music. I need OS X to reconnect to my network share for iTunes to access its files and Frontrow to have access to my Movies folder that I run from NAS.

Here is a great solution that will allow Tiger to automatically run any script when it awakes from sleep (or before going to sleep). Here is what you do:

Summary:
Install Sleepwatcher 2.0.5 and configure to run you’re a script to run when the mac awakes from sleep. The script will mount your remote connection (or anything else you would like to run)

Create SMB Connection Script:
Firstly create the following script to connect to an SMB network drive. This script will mount a SMB share and will not mount if it is already mounted. I used ~/Applications/Applescript/Script Editor. Enter your configuration details in the above bold caps text:

tell application "Finder"
if not (exists disk "SHARE_NAME") then mount volume "smb://NAS_NAME/SHARE_NAME/" as user name "USER" with password "PASSWORD"
end tell


When done, save the script as:
File Name: MountNASDrive.app
File Format: Application
Location: ~/Applications/

Finally, add the script application to my dock (drag and drop from the apps folder to the dock), the set it to Open at Login.

Install the Sleepwatcher application:

Download Sleepwatcher 2.0.5 from http://www.bernhard-baehr.de/
1) First install Sleepwatcher.pkg
2) Secondly install Sleepwatcher StartupItem.pkg

Thanks to Bernhard Baehr who has created this excellent application. Sleepwatcher captures the OS X alerts when the system enters sleep or awakes from sleep. When it sees this alert it runs either ~/.sleep or ~/.wakeup as appropriate (btw the user needs to create these scripts in the user folder themselves). The scripts can run actions or call applications or other scripts.

Create the Sleepwatcher configuration files:

sudo nano ~/.wakeup

#!/bin/sh
echo 'sleep 0.5
logger -t sleepwatcher "connecting to the network drive"
open /Applications/MountNASDrive.app' | /bin/sh&

sudo nano ~/.sleep

Leave this file blank (this file runs any actions before the mac goes to sleep)

Apply permissions to the Sleepwatcher configuration files:

Use terminal to apply permissions for the .wakeup file

chmod 755 ~/.wakeup
chmod +x ~/.wakeup
ls -al | grep .wakeup

The response should look like this:
-rwxr-xr-x 1 username username 142 Dec 27 22:54 .wakeup

Then check then apply permissions for the .sleep file

chmod 755 ~/.sleep
chmod +x ~/.sleep
ls -al | grep .sleep

The response should look like this:
-rwxr-xr-x 1 username username 176 Dec 27 20:49 .sleep

Done:

The installation is complete and should work without a reboot. Personally I did, just to make sure all services were started.

Movies Folder Config:

As an additional benefit for Front Row, create an alias of your Movies folder on the NAS and copy this alias to your ~/Movies folder. This will allow Front Row to access all your movies from your NAS drive. If you have a large photo library, you can use the same alias method for your Photo library.

References:

Here are some links for configuring Sleepwatcher:

http://www.bernhard-baehr.de/
http://www.20seven.org/blog/articles...cs-and-my-nas/
http://www.macosxhints.com/article.p...60908113605812
http://thegrebs.com/docs/reconnect_iterm.html
http://www.macgeekery.com/tips/autom...le_kill_it_all
http://www.mactype.com/software/how-...epair-team.php
http://www.versiontracker.com/dyn/moreinfo/macosx/17579

Here are some links regarding iTune Library relocation options and methods:

http://www.20seven.org/blog/articles...cs-and-my-nas/
http://tech.kateva.org/2005/01/movin...b-version.html
http://www.macosxhints.com/article.p...60127152927466
http://www.macosxhints.com/article.p...unes%2Blibrary
http://forums.obdev.at/viewtopic.php...b4d249dbdea8be

Note: Leopard has AUTOFS, which can be configured to automatically mount network shares.
gregz is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #2 (permalink)  
Old 01-01-2008, 02:05 PM
Stuck in IKEA. Send help.

Group: Administrators
Location: St. Albans, Melbourne
Blog Entries: 11


Nice tip for the 10.4 users
decryption is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #3 (permalink)  
Old 01-01-2008, 02:59 PM
Regular

Group: Regulars
Location: Brisbane


any reason you are using smb (and not afs) for networking?
__________________
the answer is yes, I am an old curmudgeon
its not irony, its sarcasm
If you must have the last word, then I suppose you must
antechinus55 is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #4 (permalink)  
Old 01-01-2008, 04:31 PM
Stuck in IKEA. Send help.

Group: Administrators
Location: St. Albans, Melbourne
Blog Entries: 11


Quote:
Originally Posted by antechinus55 View Post
any reason you are using smb (and not afs) for networking?
I'm guessing it's because non-Macs need access to the network shares.
decryption is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #5 (permalink)  
Old 01-01-2008, 06:18 PM
Member

Group: Regulars
Location: Sydney


Exactly, my NAS runs SMB for sharing with a PC network.
I run copper from the NAS and Mac and wireless for everything else.

Thanks.
gregz is offline
Profile CardPM
Go to the top of the page
Reply With Quote
 
Reply

Thread Tools

 
Similar Threads
 
Thread Thread Starter Forum Replies Last Post
How to Auto Reconnect Network drive after sleep? gregz Mac OS X & All Software 5 31-07-2008 12:27 PM
Western Digital drive management auto on/off does not work on firewire? begbie Peripherals 6 17-10-2007 09:40 AM
Network solution Nathanh Peripherals 3 19-06-2007 10:16 PM
Network Backup Server Solution? ilostmypassword Apple General 2 13-08-2006 12:51 PM
Network - Auto Connecting? plunkotica Help and New Mac User Support 6 07-02-2006 12:24 AM