]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - debian/nfs-common.init
Imported Debian patch 1.1.1~git-20070709-5
[nfs-utils.git] / debian / nfs-common.init
index c6b0a9a284ca79a4baf7011b14c4f68a6d15fa63..2bfa59d2339961fd67897ec8e598db4644b19c7d 100644 (file)
@@ -2,9 +2,9 @@
 
 ### BEGIN INIT INFO
 # Provides:          nfs-common
-# Required-Start:    $time
+# Required-Start:    $portmap $time
 # Required-Stop:     $time
-# Default-Start:     2 3 4 5
+# Default-Start:     2 3 4 5 S
 # Default-Stop:      0 1 6
 # Short-Description: NFS support files common to client and server
 # Description:       NFS is a popular protocol for file sharing across
@@ -36,21 +36,23 @@ fi
 AUTO_NEED_IDMAPD=no
 AUTO_NEED_GSSD=no
 
-exec 9<&0 </etc/fstab
+if [ -f /etc/fstab ]; then
+    exec 9<&0 </etc/fstab
 
-while read DEV MTPT FSTYPE OPTS REST
-do
-    if [ "$FSTYPE" = "nfs4" ]; then
-        AUTO_NEED_IDMAPD=yes
-    fi
-    case "$OPTS" in
-        sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5i,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
-           AUTO_NEED_GSSD=yes
-       ;;
-    esac
-done
-
-exec 0<&9 9<&-
+    while read DEV MTPT FSTYPE OPTS REST
+    do
+        if [ "$FSTYPE" = "nfs4" ]; then
+            AUTO_NEED_IDMAPD=yes
+        fi
+        case "$OPTS" in
+            sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5i,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
+           AUTO_NEED_GSSD=yes
+            ;;
+        esac
+    done
+
+    exec 0<&9 9<&-
+fi
 
 #
 # We also need idmapd if we run an NFSv4 server. It's fairly difficult
@@ -61,7 +63,7 @@ exec 0<&9 9<&-
 # condition in nfs-kernel-server's init script does, which has a value in
 # itself.
 #
-if [ -f /etc/exports ]; then
+if [ -f /etc/exports ] && grep -q '^[[:space:]]*[^#]*/' /etc/exports; then
     AUTO_NEED_IDMAPD=yes
 fi
 
@@ -82,11 +84,6 @@ case "$NEED_GSSD" in
        ;;
 esac
 
-# Exit if required binaries are missing.
-[ -x $PREFIX/sbin/rpc.statd ] || exit 0
-[ -x /usr/sbin/rpc.idmapd   ] || [ "$NEED_IDMAPD" = no ] || exit 0
-[ -x /usr/sbin/rpc.gssd     ] || [ "$NEED_GSSD"   = no ] || exit 0
-
 do_modprobe() {
     if [ -x /sbin/modprobe -a -f /proc/modules ]
     then
@@ -128,6 +125,11 @@ case "$1" in
            exit $?
        fi
 
+       # Don't start idmapd and gssd if we don't have them (say, if /usr is not
+       # up yet).
+       [ -x /usr/sbin/rpc.idmapd ] || NEED_IDMAPD=no
+       [ -x /usr/sbin/rpc.gssd   ] || NEED_GSSD=no
+
        if [ "$NEED_IDMAPD" = yes ] || [ "$NEED_GSSD" = yes ]
        then
            do_modprobe nfs