[Pkg-sysvinit-devel] Bug#390404: initscripts: /etc/network/if-up.d/mountnfs does not mount nfs directory at boot time

Petter Reinholdtsen pere at hungry.com
Fri Oct 20 23:59:23 CEST 2006


> BTW, the dangling /var/run/network/mountnfs was left behind because
> at some point I used "CTRL-C" to kill the hanging script and I
> didn't realize even the existence of the lock directory at that
> time.

Right.  Can you try this patch and see if it solve that problem?

  * Add exit handler in if-up.d/mountnfs to make sure the lock directory
    is removed when the script is interrupted.
  * Print message when refusing to mount directoryes because the
    lockdir exist.

Index: debian/initscripts/etc/network/if-up.d/mountnfs
===================================================================
--- debian/initscripts/etc/network/if-up.d/mountnfs     (revision 1017)
+++ debian/initscripts/etc/network/if-up.d/mountnfs     (working copy)
@@ -131,8 +131,18 @@

 # Lock around this otherwise insanity may occur
 mkdir /var/run/network          2>/dev/null || true
-mkdir /var/run/network/mountnfs 2>/dev/null || exit 0

+if mkdir /var/run/network/mountnfs 2>/dev/null ; then
+    :
+else
+    echo "if-up.d/mountnfs: lockdir /var/run/network/mountnfs exist, not doing NFSmounting"
+    exit 0
+fi
+
+on_exit() {
+    # Clean up lock when script exits, even if it is interrupted
+    rmdir /var/run/network/mountnfs 2>/dev/null || exit 0
+}
+trap on_exit EXIT # Enable emergency handler
+
 do_start
-
-rmdir /var/run/network/mountnfs 2>/dev/null || exit 0

I'm not quite sure how to best handle the issue with NFS mounting and
several network interfaces, but thought it should be possible to at
least handle the interrupted script case better.

[Wolf Wiegand]
> Will there be problems if 
> 
> mkdir /var/run/network/mountnfs 2>/dev/null || exit 0
> 
> is changed to
> 
> mkdir -p /var/run/network/mountnfs 2>/dev/null || exit 0

Yes.  This will disable the locking completely.  The mkdir command
will no longer fail when the lock already exist, and two instances of
mountnfs might run at the same time.

> ? In any case, if the scripts exits and does not mount shares due to
> an error, it should not exit with 0 (or is this required by
> anything?) and should print out a short description why it exited
> (for example "Lock directory /var/run/network/mountnfs already
> exists. This should not happen, exiting.").

I agree that some message should be printed.  I'm not sure about the
exit code, so I leave that as it is.

Friendly,
-- 
Petter Reinholdtsen




More information about the Pkg-sysvinit-devel mailing list