Share a music/photo hard drive between two systems

Jun 23, '09 07:30:03AM

Contributed by: spartanoverseas

I store all my photos (iPhoto) and music (iTunes) on an external FireWire drive. Normally the drive is attached to my iMac, but when I travel, I take the external hard drive and hook it up to my laptop. I want to have my iTunes work whether or not the drive is attached, and have it work automatically.

The quick summary of my solution is:

Read on for the scripts I use...

My Mounting Script:

#!/bin/bash

HOME=/Users/username
GRAID_MOUNT="/Volumes/G-RAID_MINI"

IPHOTO_TAIL="iPhoto_Library"
IPHOTO_TAIL_LOCAL="iPhoto_Library.local"
IPHOTOLIBRARY_LINK=$HOME/Pictures/$IPHOTO_TAIL
IPHOTO_GRAID=$GRAID_MOUNT/Photos/$IPHOTO_TAIL
IPHOTO_LOCAL=$HOME/Pictures/$IPHOTO_TAIL_LOCAL

ITUNES_LINK=$HOME/Music/iTunes
ITUNES_GRAID=$GRAID_MOUNT/Music/iTunes
ITUNES_LOCAL=$HOME/Music/iTunes.local

if [ -d $GRAID_MOUNT ]; then
  echo ........ G-RAID MOUNTING ..........
  `rm  $IPHOTOLIBRARY_LINK `
  `ln -s $IPHOTO_GRAID $IPHOTOLIBRARY_LINK`
  `rm $ITUNES_LINK`
  `ln -s $ITUNES_GRAID $ITUNES_LINK`

echo DONE CHANGING IPHOTO AND ITUNES LINKS 
exit 0
fi

echo ERROR DISK NOT MOUNTED
My Unmounting Script
#!/bin/bash

HOME=/Users/username
GRAID_MOUNT="/Volumes/G-RAID_MINI"


IPHOTO_TAIL="iPhoto_Library"
IPHOTO_TAIL_LOCAL="iPhoto_Library.local"
IPHOTOLIBRARY_LINK=$HOME/Pictures/$IPHOTO_TAIL
IPHOTO_GRAID=$GRAID_MOUNT/Photos/$IPHOTO_TAIL
IPHOTO_LOCAL=$HOME/Pictures/$IPHOTO_TAIL_LOCAL

ITUNES_LINK=$HOME/Music/iTunes
ITUNES_GRAID=$GRAID_MOUNT/Music/iTunes
ITUNES_LOCAL=$HOME/Music/iTunes.local

if [ -d $GRAID_MOUNT ]; then
  echo  GRAID NOT UNMOUNTED  
  exit 0; 
fi

echo .....  GRAID IS BEING UNMOUNTED
`rm  $IPHOTOLIBRARY_LINK `
`ln -s $IPHOTO_LOCAL $IPHOTOLIBRARY_LINK`
`rm $ITUNES_LINK`
`ln -s $ITUNES_LOCAL $ITUNES_LINK`

echo    DONE UNMOUNTING GRAID
Lingon Changes I added two agents to Lingon: The only catch I've found is that there are major problems with this script if spaces exist in the file name -- the bash scripts seem to have a very hard time with the space issue. I couldn't find a solution in scripting, so I simply changed the names of the folders and had iTunes/iPhoto point to an underscore instead. Same goes for the external hard disk.

If anyone sees any errors in this, or has any thoughts on a better way to get this done, I'd be interested in reading what you have to say.

Comments (12)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20090621015649375