[Pkg-sysvinit-commits] r822 - in sysvinit/trunk/debian: .
initscripts initscripts/etc initscripts/etc/init.d
initscripts/etc/network initscripts/etc/network/if-up.d
Petter Reinholdtsen
pere at costa.debian.org
Tue Sep 5 09:29:06 UTC 2006
Author: pere
Date: 2006-09-05 09:29:06 +0000 (Tue, 05 Sep 2006)
New Revision: 822
Added:
sysvinit/trunk/debian/initscripts/etc/network/
sysvinit/trunk/debian/initscripts/etc/network/if-up.d/
sysvinit/trunk/debian/initscripts/etc/network/if-up.d/mountnfs
Modified:
sysvinit/trunk/debian/changelog
sysvinit/trunk/debian/initscripts/conffiles
sysvinit/trunk/debian/initscripts/etc/init.d/mountnfs.sh
sysvinit/trunk/debian/rules
Log:
* Move NFS mounting to an if-up.d script, to make sure we try to
mount NFS file systems after the network is available. Based on
patch from Ubuntu. Modified to rewrite mountnfs.sh instead of
renaming it to waitnfs.sh. (Closes: #360123
Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog 2006-09-05 09:16:26 UTC (rev 821)
+++ sysvinit/trunk/debian/changelog 2006-09-05 09:29:06 UTC (rev 822)
@@ -14,6 +14,10 @@
* Mount /dev/shm, /sys, /proc and /proc/bus/usb using
noexec,nodev,nosuid to make it harder to misuse.
(Closes: #378182, #378280)
+ * Move NFS mounting to an if-up.d script, to make sure we try to
+ mount NFS file systems after the network is available. Based on
+ patch from Ubuntu. Modified to rewrite mountnfs.sh instead of
+ renaming it to waitnfs.sh. (Closes: #360123
-- Petter Reinholdtsen <pere at debian.org> Wed, 26 Jul 2006 11:37:23 +0200
Modified: sysvinit/trunk/debian/initscripts/conffiles
===================================================================
--- sysvinit/trunk/debian/initscripts/conffiles 2006-09-05 09:16:26 UTC (rev 821)
+++ sysvinit/trunk/debian/initscripts/conffiles 2006-09-05 09:29:06 UTC (rev 822)
@@ -28,3 +28,4 @@
/etc/default/devpts
/etc/default/halt
/etc/default/tmpfs
+/etc/network/if-up.d/mountnfs
Modified: sysvinit/trunk/debian/initscripts/etc/init.d/mountnfs.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/mountnfs.sh 2006-09-05 09:16:26 UTC (rev 821)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/mountnfs.sh 2006-09-05 09:29:06 UTC (rev 822)
@@ -5,37 +5,27 @@
# Required-Stop:
# Default-Start: S
# Default-Stop:
-# Short-Description: Mount network file systems.
-# Description: Now that TCP/IP is configured, mount the NFS file
-# systems in /etc/fstab if needed. If possible,
-# start the portmapper before mounting (this is needed for
-# Linux 2.1.x and up).
-#
-# Also mounts SMB filesystems now, so the name of
-# this script is getting increasingly inaccurate.
+# Short-Description: Wait for network file systems to be mounted
+# Description: Network file systems are mounted by
+# /etc/network/if-up.d/mountnfs in the background
+# when interfaces are brought up; this script waits
+# for them to be mounted before carrying on.
### END INIT INFO
-PATH=/sbin:/bin
-. /lib/init/vars.sh
-
+[ -f /etc/default/rcS ] && . /etc/default/rcS
. /lib/lsb/init-functions
do_start() {
[ -f /etc/fstab ] || return
#
# Read through fstab line by line. If it is NFS, set the flag
- # for mounting NFS file systems. If any NFS partition is found and it
- # not mounted with the nolock option, we start the portmapper.
- #
- # If any sec={krb5,krb5i,krb5p} option is given, or any of the file
- # systems are nfs4, we'll need to start rpc.gssd and/or rpc.idmapd too;
- # we'll leave that to nfs-common.
+ # for mounting NFS file systems. If any NFS partition is found
+ # then wait around for it.
#
exec 9<&0 </etc/fstab
- portmap=no
- gss_or_idmap=no
+ waitnfs=
while read DEV MTPT FSTYPE OPTS REST
do
case "$DEV" in
@@ -49,126 +39,62 @@
;;
esac
case "$FSTYPE" in
- nfs|nfs4)
- case "$OPTS" in
- nolock|*,nolock|nolock,*|*,nolock,*)
- ;;
- *)
- portmap=yes
- ;;
- esac
- 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,*)
- gss_or_idmap=yes
- ;;
- esac
+ nfs|nfs4|smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs)
;;
- smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs)
- ;;
*)
- FSTYPE=
+ continue
;;
esac
- if [ "$FSTYPE" ]
- then
- case "$NETFS" in
- $FSTYPE|*,$FSTYPE|$FSTYPE,*|*,$FSTYPE,*)
- ;;
- *)
- NETFS="$NETFS${NETFS:+,}$FSTYPE"
- ;;
- esac
- fi
- if [ "$FSTYPE" = "nfs4" ]
- then
- gss_or_idmap=yes
- fi
+ case "$MTPT" in
+ /usr/local|/usr/local/*)
+ ;;
+ /usr|/usr/*)
+ waitnfs="$waitnfs $MTPT"
+ ;;
+ /var|/var/*)
+ waitnfs="$waitnfs $MTPT"
+ ;;
+ esac
done
exec 0<&9 9<&-
- #
- # With contemporary portmap packages it is no longer necessary
- # to start portmap here because the package has its own initscript.
- # This code will disappear after etch.
- #
- if [ "$portmap" = yes ]
- then
- if [ -x /sbin/portmap ] && ! pidof portmap >/dev/null 2>&1
- then
- if [ -x /etc/init.d/portmap ]
- then
- /etc/init.d/portmap start
- else
- log_action_begin_msg "Starting portmap"
- start-stop-daemon --start --quiet --oknodo --exec /sbin/portmap
- ES=$?
- sleep 1 # FIXME: Actually synchronize with the process?
- log_action_end_msg $ES
- fi
- fi
- fi
+ # Wait for each path, the timeout is for all of them as that's
+ # really the maximum time we have to wait anyway
+ TIMEOUT=900
+ for mountpt in $waitnfs; do
+ log_action_begin_msg "Waiting for $mountpt"
- #
- # Initialize nfs-common (which starts rpc.gssd and/or rpc.idmapd, and loads
- # the right kernel modules if applicable) if we use Kerberos and/or NFSv4 mounts.
- #
- if [ "$gss_or_idmap" = yes ] && [ -x /etc/init.d/nfs-common ]
- then
- /etc/init.d/nfs-common start
- fi
+ while ! mountpoint -q $mountpt; do
+ sleep 0.1
- if [ "$NETFS" ]
- then
- mount_all_nfs() { mount -a -t$NETFS ; }
-
- # Accept 64 or 96 (32/mount failure + 64/some mount succeeded)
- # as valid return statuses from mount. This partly works around
- # the problem of mount reporting an error status when
- # some filesystems are already mounted.
-
- if [ "$VERBOSE" = no ]
- then
- log_action_begin_msg "Mounting remote filesystems"
- MOUNT_OUT="$(LC_ALL=C mount_all_nfs)"
- ES=$?
- echo "$MOUNT_OUT" | sed -e '/already mounted/d' -e '/nothing was mounted/d'
- if [ 0 = "$ES" ] || [ 96 = "$ES" ] || [ 64 = "$ES" ]
- then
- log_action_end_msg 0
- else
- log_action_end_msg 1 "code $ES"
+ TIMEOUT=$(( $TIMEOUT - 1 ))
+ if [ $TIMEOUT -le 0 ]; then
+ log_action_end_msg 1
+ break
fi
- else
- log_action_msg "Will now mount remote filesystems"
- mount_all_nfs
- ES=$?
- if [ 0 = "$ES" ] || [ 96 = "$ES" ] || [ 64 = "$ES" ]
- then
- log_success_msg "Done mounting remote filesystems."
- else
- log_failure_msg "Mounting remote filesystems failed with error code ${ES}."
- fi
+ done
+
+ if [ $TIMEOUT -gt 0 ]; then
+ log_action_end_msg 0
fi
- fi
+ done
}
-
case "$1" in
- start|"")
- do_start
- ;;
- restart|reload|force-reload)
- echo "Error: argument '$1' not supported" >&2
- exit 3
- ;;
- stop)
- # No-op
- ;;
- *)
- echo "Usage: mountnfs.sh [start|stop]" >&2
- exit 3
- ;;
+ start)
+ do_start
+ ;;
+ restart|reload|force-reload)
+ echo "Error: argument '$1' not supported" >&2
+ exit 3
+ ;;
+ stop)
+ ;;
+ *)
+ echo "Usage: $0 start|stop" >&2
+ exit 3
+ ;;
esac
-:
+: exit 0
Added: sysvinit/trunk/debian/initscripts/etc/network/if-up.d/mountnfs
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/network/if-up.d/mountnfs (rev 0)
+++ sysvinit/trunk/debian/initscripts/etc/network/if-up.d/mountnfs 2006-09-05 09:29:06 UTC (rev 822)
@@ -0,0 +1,132 @@
+#! /bin/sh
+# Description: Now that TCP/IP is configured, mount the NFS file
+# systems in /etc/fstab if needed. If possible,
+# start the portmapper before mounting (this is needed for
+# Linux 2.1.x and up).
+#
+# Also mounts SMB filesystems now, so the name of
+# this script is getting increasingly inaccurate.
+
+PATH=/sbin:/bin
+. /lib/init/vars.sh
+
+. /lib/lsb/init-functions
+
+do_start() {
+ [ -f /etc/fstab ] || return
+ #
+ # Read through fstab line by line. If it is NFS, set the flag
+ # for mounting NFS file systems. If any NFS partition is found and it
+ # not mounted with the nolock option, we start the portmapper.
+ #
+ # If any sec={krb5,krb5i,krb5p} option is given, or any of the file
+ # systems are nfs4, we'll need to start rpc.gssd and/or rpc.idmapd too;
+ # we'll leave that to nfs-common.
+ #
+
+ exec 9<&0 </etc/fstab
+
+ portmap=no
+ gss_or_idmap=no
+ while read DEV MTPT FSTYPE OPTS REST
+ do
+ case "$DEV" in
+ ""|\#*)
+ continue
+ ;;
+ esac
+ case "$OPTS" in
+ noauto|*,noauto|noauto,*|*,noauto,*)
+ continue
+ ;;
+ esac
+ case "$FSTYPE" in
+ nfs|nfs4)
+ case "$OPTS" in
+ nolock|*,nolock|nolock,*|*,nolock,*)
+ ;;
+ *)
+ portmap=yes
+ ;;
+ esac
+ 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,*)
+ gss_or_idmap=yes
+ ;;
+ esac
+ ;;
+ smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs)
+ ;;
+ *)
+ FSTYPE=
+ ;;
+ esac
+ if [ "$FSTYPE" ]
+ then
+ case "$NETFS" in
+ $FSTYPE|*,$FSTYPE|$FSTYPE,*|*,$FSTYPE,*)
+ ;;
+ *)
+ NETFS="$NETFS${NETFS:+,}$FSTYPE"
+ ;;
+ esac
+ fi
+ if [ "$FSTYPE" = "nfs4" ]
+ then
+ gss_or_idmap=yes
+ fi
+ done
+
+ exec 0<&9 9<&-
+
+ #
+ # With contemporary portmap packages it is no longer necessary
+ # to start portmap here because the package has its own initscript.
+ # This code will disappear after etch.
+ #
+ if [ "$portmap" = yes ]
+ then
+ if [ -x /sbin/portmap ] && ! pidof portmap >/dev/null 2>&1
+ then
+ if [ -x /etc/init.d/portmap ]
+ then
+ /etc/init.d/portmap start
+ else
+ start-stop-daemon --start --quiet --oknodo --exec /sbin/portmap
+ sleep 1 # FIXME: Actually synchronize with the process?
+ fi
+ fi
+ fi
+
+ #
+ # Initialize nfs-common (which starts rpc.gssd and/or rpc.idmapd, and loads
+ # the right kernel modules if applicable) if we use Kerberos and/or NFSv4 mounts.
+ #
+ if [ "$gss_or_idmap" = yes ] && [ -x /etc/init.d/nfs-common ]
+ then
+ /etc/init.d/nfs-common start
+ fi
+
+ if [ "$NETFS" ]
+ then
+ mount_all_nfs() { mount -a -t$NETFS ; }
+
+ # Accept 64 or 96 (32/mount failure + 64/some mount succeeded)
+ # as valid return statuses from mount. This partly works around
+ # the problem of mount reporting an error status when
+ # some filesystems are already mounted.
+
+ mount_all_nfs
+ fi
+}
+
+
+# Not for loopback!
+[ "$IFACE" != "lo" ] || exit 0
+
+# Lock around this otherwise insanity may occur
+mkdir /var/run/network/mountnfs 2>/dev/null || exit 0
+
+do_start
+
+rmdir /var/run/network/mountnfs 2>/dev/null || exit 0
Modified: sysvinit/trunk/debian/rules
===================================================================
--- sysvinit/trunk/debian/rules 2006-09-05 09:16:26 UTC (rev 821)
+++ sysvinit/trunk/debian/rules 2006-09-05 09:29:06 UTC (rev 822)
@@ -130,6 +130,7 @@
cp -afv debian/initscripts/etc/* $(tmp)/etc
cp -afv debian/initscripts/lib/* $(tmp)/lib
chmod 755 $(tmp)/etc/init.d/[a-z]*
+ chmod 755 $(tmp)/etc/network/if-up.d/[a-z]*
chmod 644 $(tmp)/lib/init/*.sh
chmod -R g-w $(tmp)
chown -R root:root $(tmp)
More information about the Pkg-sysvinit-commits
mailing list