[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: prevent writing to unmounted directory



On Thu, Apr 24, 2008 at 10:18:48PM +0200, Chris wrote:
> On Thursday 24 April 2008, Bob McGowan wrote:
> > Chris wrote:
> > > Hello,
> > >
> > > I want to run a script to rsync local files to a NAS mounted to
> > > /mnt/music. Sometimes the NAS is not running, and I want to prevent the
> > > script from writing to the mount directory:  is there any easy way to
> > > prevent this?
> > >
> > > Thanks,
> > >
> > > C
> >
> > if [ -f /mnt/music/somefile ]
> > then
> >    # run your script here.
> > fi
> 
> hey, cool.  I wouldn't have expected anything like this!

another alternative, since it's likely that the contents of /mnt/music could
change (I know mine does), why not do this.

umount /mnt/music
touch /mnt/music/SENTINEL

then do 

if [ -f /mnt/music/SENTINEL ]
then
	echo "Music share is not mounted!"
	exit 1;
fi

#run your script here

the only way SENTINEL will appear is when the NAS is *not*
mounted. And this protects whatever you are using as your SENTINEL
from inadvertent deletion.

A

Attachment: signature.asc
Description: Digital signature


Reply to: