Shirt Pocket Discussions  
    Home netTunes launchTunes SuperDuper! Buy Now Support Discussions About Shirt Pocket    

Go Back   Shirt Pocket Discussions > SuperDuper! > General

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-09-2007, 05:24 PM
afragen afragen is offline
Registered User
 
Join Date: May 2007
Location: Southern California
Posts: 13
Send a message via AIM to afragen
I've written a shell script that will do something just like this. What it does is check the MAC address of your current router. If that MAC address has changed then it will force dismount any AFP mounted disks and maybe any SSHFS mounted disks. I have this script run every minute via a launchd process that I set up with Lingon. The script will log its activity if you set it up that way. Here's the script. If you have any problems let me know. I've been running it here for over a month without problems.

I've name the script 'unmount.sh' Let me know what you think. If you have problems with it.

Andy
Reply With Quote
  #2  
Old 05-10-2007, 12:16 AM
digSD digSD is offline
Registered User
 
Join Date: May 2007
Posts: 6
Quote:
Originally Posted by afragen View Post
I've written a shell script that will do something just like this. ... Andy
Thanks, Andy. As I said above, I don't speak shell scripts unfortunately. My situation is a bit different: the MAC address doesn't change, but the Mac containing the backup disk (which has file sharing turned on) goes to sleep after backups finish (overnight). Since the server icon is left on the desktops of the other Macs by SD, I get spinning beach balls until OSX decides to offer to "disconnect" the server, which can take a while and is most annoying. The only way to avoid this is to get in the habit of remembering to select and eject the server each time I wake up one of those Macs, before doing anything else.

If only SD would disconnect the server (after unmounting the disk image file)... IOW if it could just reverse the procedure it does before copying...

Not sure I'm making myself clear. It's just an annoyance factor, nothing more.

Last edited by digSD; 05-10-2007 at 12:18 AM.
Reply With Quote
  #3  
Old 05-10-2007, 10:30 AM
dnanian's Avatar
dnanian dnanian is offline
Administrator
 
Join Date: Apr 2001
Location: Weston, MA
Posts: 14,933
Send a message via AIM to dnanian
The script the user has provided can do this for you... I do understand what you want, but there are issues there that make this more difficult than you might expect at first...
__________________
--Dave Nanian
Reply With Quote
  #4  
Old 05-10-2007, 06:40 PM
afragen afragen is offline
Registered User
 
Join Date: May 2007
Location: Southern California
Posts: 13
Send a message via AIM to afragen
This script will do exactly what you want. I think.

Code:
#!/usr/bin/env bash

sleep 45

if [[ `mount | awk '/^afp_/'` != "" ]]; then
  # http://www.macosxhints.com/article.p...51107175256782
  mount | awk '/^afp_/ { system("umount -f " $3) }'
  echo $now "afp disk unmounted"
fi
Save it and set it to executable. You'll then have to call it from within SD's Advanced settings to run the shell script after copy completes.

Dave, if you want to include this script with SD feel free.

Andy
Reply With Quote
  #5  
Old 05-10-2007, 08:48 PM
dnanian's Avatar
dnanian dnanian is offline
Administrator
 
Join Date: Apr 2001
Location: Weston, MA
Posts: 14,933
Send a message via AIM to dnanian
Well... this won't handle SMB mounted drives and assumes that there's a single network volume attached. But I appreciate the post, and hope others will find it useful.

As an aside, I can't tell you how happy I am to see members of the SuperDuper/Shirt Pocket community contributing solutions. It's really greatly appreciated: thanks to everyone who's chipping in!
__________________
--Dave Nanian
Reply With Quote
  #6  
Old 05-11-2007, 12:37 AM
afragen afragen is offline
Registered User
 
Join Date: May 2007
Location: Southern California
Posts: 13
Send a message via AIM to afragen
What can I say, I don't have an SMB mounted drive. If you can provide me with the results of a 'mount' command with and SMB mounted drive I'm sure I can adapt the script for that as well.

You could always loop the unmount commands through a loop for the number of AFP or other mounted drives. I'm fairly sure some sort of grep command can count the number of hits to that particular search string.

But I do understand that the script isn't universal and as such might not be useful to everyone. But I'm glad someone else can find it useful.
Reply With Quote
  #7  
Old 05-11-2007, 12:56 AM
afragen afragen is offline
Registered User
 
Join Date: May 2007
Location: Southern California
Posts: 13
Send a message via AIM to afragen
Quote:
Originally Posted by dnanian View Post
and assumes that there's a single network volume attached.!
This will/should work for multiple attached network AFP mounts. I'm sure something similar would work for any other mount type.

Code:
#!/usr/bin/env bash

sleep 45

if [[ `mount | awk '/^afp_/'` != "" ]]; then
  num_mounts=`mount | grep -c ^afp`
  for (( i = 0; i < $num_mounts; i++ )); do
    afp=`mount | grep ^afp_ | awk {'print$3'} | sed -n '1p;1q'`
    umount -f $afp
  done
fi
Andy

Last edited by afragen; 05-11-2007 at 02:19 AM.
Reply With Quote
  #8  
Old 05-11-2007, 04:12 AM
chris_johnsen chris_johnsen is offline
Registered User
 
Join Date: Jan 2007
Posts: 79
concise shell script examples

(The shell script code fragments below are untested since I don't have any AFP volumes, but people developing shell scripts might find the techniques useful.)

Here are some variations that I find a bit more natural for shell scripting:

Code:
mount | awk '/^afp_/ {print $3}' | xargs -n 1 umount -f
The -n 1 might not be needed on the xargs, but it results in the same umount invocations as the previous script (one per volume). Leaving the -n 1 off would put all the volumes into one umount invocation.

Of course, if you really want to always unmount all AFP volumes, something like this might work, too:

Code:
umount -Aft afp
That last variation is probably OK for AFP, but it is inappropriate for NFS since there are several NFS mediated mounts (automount) that are present on most systems (/Network, /Network/Servers, etc.). Changing afp to nfs in that last command would unmount these normal "volumes", too, which probably is not what the user really wants. Something like the first example with an extra pattern in the awk and/or an extra grep before the awk to select just the target volumes would probably be better for NFS volumes.

BTW, head -1 has the same result as sed -n '1p;1q', and is usually much easier to understand for those not versed in sed/ex/vi.
Reply With Quote
  #9  
Old 08-21-2007, 01:55 PM
afragen afragen is offline
Registered User
 
Join Date: May 2007
Location: Southern California
Posts: 13
Send a message via AIM to afragen
Dave, could you post the contents of the 'mount' command when SMB shares are mounted? I'm trying to adapt my unmount script to handle afp, sshfs and smb shares. Unfortunately I don't have sshfs or smb shares to test with. TIA.

BTW, the script is always up at http://thefragens.com/pub/

Last edited by afragen; 08-21-2007 at 06:16 PM.
Reply With Quote
  #10  
Old 05-10-2007, 09:13 PM
digSD digSD is offline
Registered User
 
Join Date: May 2007
Posts: 6
Thank you

Preliminary testing shows this does indeed work for me. Thank you!
Reply With Quote
  #11  
Old 05-11-2007, 12:30 AM
afragen afragen is offline
Registered User
 
Join Date: May 2007
Location: Southern California
Posts: 13
Send a message via AIM to afragen
You're welcome.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Smart Update copying files that haven't been changed? salparadi General 3 11-05-2006 11:40 AM
Copying newer files across volumes. chip General 1 08-09-2006 08:07 PM
Long Hang While Copying BackerUpper General 4 06-12-2006 08:26 AM
SuperDuper! Erasing Audio Files? Emerson General 3 06-22-2005 01:41 PM
Smart update copying all files each time fabius General 15 05-29-2005 09:29 PM


All times are GMT -4. The time now is 02:58 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2026, vBulletin Solutions, Inc.