[PLUG] NFS monitored mount

Shantanoo Mahajan shantanoo at gmail.com
Mon Sep 24 09:25:47 PDT 2007


On 24-Sep-07, at 3:27 PM, श्रीधर नारायण  
दैठणकर wrote:

> On Monday 24 Sep 2007 15:09:51 Ketan Padegaonkar wrote:
>> On 9/24/07, Aditya Godbole <aag.lists at gmail.com> wrote:
>>> Hi,
>>> I want to mount a NFS share if it has not been mounted already. The
>>> program should  return success if the share is already mounted or if
>>> it gets mounted successfully, and failure otherwise.
>>> Is there any existing script/daemon I can use?
>>
>> Did you look at autofs and automount ?
>> (http://tldp.org/HOWTO/Automount.html)
>
> Also isn't this simple enough?
>
> if [  `mount|grep <mountpoint> >|wc -l` -eq 0 ]; then
if [ `mount | grep <mountpoint> | grep <device> | wc -l` -eq 0 ]; then
> 	mount <mountpoint>;
	mount <device> <mountpoint>; exit $?
> else
> 	echo "<mountpoint> is already mounted";
	ls <mountpoint> > /dev/null;
	exit $?
> fi
>
> Actually just blindly mount works too. It gives a warning which you  
> can ignore
> but at the end share is guaranteed to be mounted :)

Its better not to use it blindly. I have seen a situation where two  
different devices
were mounted on the same mount point.

shantanoo


More information about the plug-mail mailing list