[SSI] openssi/nfs-utils.more nfs.init, 1.1.15.1, 1.1.15.2 nfslock.init, 1.1.15.1, 1.1.15.2

Roger Tsang <[email protected]> Thu, 15 Jul 2010 03:28:38 +0000
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/nfs-utils.more
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv9812

Modified Files:
      Tag: CENTOS
	nfs.init nfslock.init 
Log Message:
Fix wrong import. Re-import from nfs-utils-1.0.6-84.EL4.src.rpm for CentOS 4


Index: nfs.init
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/nfs-utils.more/Attic/nfs.init,v
retrieving revision 1.1.15.1
retrieving revision 1.1.15.2
diff -u -d -r1.1.15.1 -r1.1.15.2
--- nfs.init	4 Jul 2010 22:42:11 -0000	1.1.15.1
+++ nfs.init	15 Jul 2010 03:28:36 -0000	1.1.15.2
@@ -21,127 +21,142 @@
 . /etc/sysconfig/network
 
 # Check that networking is up.
-[ "${NETWORKING}" = "no" ] && exit 6
-
-[ -x /usr/sbin/rpc.nfsd ] || exit 5
-[ -x /usr/sbin/rpc.mountd ] || exit 5
-[ -x /usr/sbin/exportfs ] || exit 5
+[ ${NETWORKING} = "no" ] && exit 0
 
-# Don't fail if /etc/exports doesn't exist; create a bare-bones version and continue.
-[ -s /etc/exports ] || \
-    { echo "#" > /etc/exports && chmod u+rw,g+r,o+r /etc/exports ; } || \
-    { echo "/etc/exports does not exist" ; exit 0 ; }
+[ -x /usr/sbin/rpc.nfsd ] || exit 0
+[ -x /usr/sbin/rpc.mountd ] || exit 0
+[ -x /usr/sbin/exportfs ] || exit 0
+[ -s /etc/exports ] || exit 0
 
 # Check for and source configuration file otherwise set defaults
+# TUNE_QUEUE: controls whether to up the size of input queues
 [ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs
 
-[ -z "$MOUNTD_NFS_V2" ] && MOUNTD_NFS_V2=default
-[ -z "$MOUNTD_NFS_V3" ] && MOUNTD_NFS_V3=default
+[ -z "$MOUNTD_NFS_V2" ] && MOUNTD_NFS_V2=auto
+[ -z "$MOUNTD_NFS_V3" ] && MOUNTD_NFS_V3=auto
 
 # Number of servers to be started by default
-[ -z "$RPCNFSDCOUNT" ] && RPCNFSDCOUNT=8
+[ -z "$NFSDCOUNT" ] && NFSDCOUNT=8
 
 # Remote quota server
 [ -z "$RQUOTAD" ] && RQUOTAD=`type -path rpc.rquotad`
 
-RETVAL=0
+# Get the initial values for the input sock queues
+# at the time of running the script.
+if [ "$TUNE_QUEUE" = "yes" ]; then
+    RMEM_DEFAULT=`/sbin/sysctl -n net.core.rmem_default`
+    RMEM_MAX=`/sbin/sysctl -n net.core.rmem_max`
+    # 256kb recommended minimum size based on SPECsfs NFS benchmarks
+    [ -z "$NFS_QS" ] && NFS_QS=262144
+fi
+
 
 # See how we were called.
 case "$1" in
   start)
-	# Start daemons.
-	[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd start
-
-	action $"Starting NFS services: " /usr/sbin/exportfs -r
-
-	# Set the ports lockd should listen on
-	if [ -n "$LOCKD_TCPPORT" ]; then
-	    /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
+	if [ -d /proc/fs/nfsd -a "$MOUNT_NFSD" = "yes" ] ; then
+	    /bin/mount -t nfsd nfsd /proc/fs/nfsd
 	fi
-	if [ -n "$LOCKD_UDPPORT" ]; then
-	    /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
+	# Start daemons.
+	# Apply input queue increase for nfs server
+	if [ "$TUNE_QUEUE" = "yes" ]; then
+ 	    /sbin/sysctl -w net.core.rmem_default=$NFSD_QS >/dev/null 2>&1
+	    /sbin/sysctl -w net.core.rmem_max=$NFSD_QS >/dev/null 2>&1
 	fi
-
+	action "Starting NFS services: " /usr/sbin/exportfs -r
 	if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
-	    echo -n $"Starting NFS quotas: "
-		[ -n "$RQUOTAD_PORT" ] \
-			&& RPCRQUOTADOPTS="$RPCRQUOTADOPTS -p $RQUOTAD_PORT"
-	    daemon rpc.rquotad $RPCRQUOTADOPTS
-		RETVAL=$?
+	    echo -n "Starting NFS quotas: "
+	    daemon rpc.rquotad
 	    echo
 	fi
-	echo -n $"Starting NFS daemon: "
-	daemon rpc.nfsd $RPCNFSDARGS $RPCNFSDCOUNT
-	RETVAL=$?
+	echo -n "Starting NFS daemon: "
+	daemon rpc.nfsd $NFSDCOUNT
 	echo
-	[ $RETVAL -ne 0 ] && exit $RETVAL
 
 	[ -n "$MOUNTD_PORT" ] \
-	&& RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
-
-	case $MOUNTD_NFS_V1 in
-	no|NO)
-	    RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 1" ;;
-	esac
+	&& MOUNTD_OPTIONS="$MOUNTD_OPTIONS -p $MOUNTD_PORT"
+	[ "$MOUNTD_TCP" = "no" -o "$MOUNTD_TCP" = "NO" ] \
+	&& MOUNTD_OPTIONS="$MOUNTD_OPTIONS --no-tcp"
 
 	case $MOUNTD_NFS_V2 in
+	auto|AUTO)
+	    # Let's see if we support NFS version 2.
+	    ClearAddr=
+	    if [ -f /proc/net/rpc/auth.unix.ip/channel ] ; then
+	       if   grep -s 127.0.0.1 /proc/net/rpc/auth.unix.ip/content > /dev/null ; then
+		    : address already known
+	       else
+                    echo nfsd 127.0.0.1 2147483647 localhost > /proc/net/rpc/auth.unix.ip/channel
+		    ClearAddr=yes
+	      fi
+	    fi
+	    /usr/sbin/rpcinfo -u localhost nfs 2 &>/dev/null
+	    if [ $? -ne 0 ]; then
+		MOUNTD_OPTIONS="$MOUNTD_OPTIONS --no-nfs-version 2"
+	    fi
+	    if [ -n "$ClearAddr" ]; then
+                  echo nfsd 127.0.0.1 1  > /proc/net/rpc/auth.unix.ip/channel
+	    fi
+	    ;;
 	no|NO)
-	    RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 2" ;;
+	    MOUNTD_OPTIONS="$MOUNTD_OPTIONS --no-nfs-version 2"
+	    ;;
+	yes|YES)
+	    MOUNTD_OPTIONS="$MOUNTD_OPTIONS --nfs-version 2"
+	    ;;
 	esac
 
 	case $MOUNTD_NFS_V3 in
+	auto|AUTO)
+	    # Let's see if we support NFS version 3.
+	    /usr/sbin/rpcinfo -u localhost nfs 3 &>/dev/null
+	    if [ $? -ne 0 ]; then
+		MOUNTD_OPTIONS="$MOUNTD_OPTIONS --no-nfs-version 3"
+	    fi
+	    ;;
 	no|NO)
-	    RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 3" ;;
+	    MOUNTD_OPTIONS="$MOUNTD_OPTIONS --no-nfs-version 3"
+	    ;;
+	yes|YES)
+	    MOUNTD_OPTIONS="$MOUNTD_OPTIONS --nfs-version 3"
+	    ;;
 	esac
 
-	echo -n $"Starting NFS mountd: "
-	daemon rpc.mountd $RPCMOUNTDOPTS
-	RETVAL=$?
+	echo -n "Starting NFS mountd: "
+	daemon rpc.mountd $MOUNTD_OPTIONS
 	echo
-	[ $RETVAL -ne 0 ] && exit $RETVAL
 	touch /var/lock/subsys/nfs
-
-	# Let rpc.idmapd know that rpc.mountd just started
-	[ -x /usr/sbin/rpc.idmapd ] && /sbin/service rpcidmapd condstart
-
+	# reset input queue for rest of network services
+	if [ "$TUNE_QUEUE" = "yes" ]; then
+	    /sbin/sysctl -w net.core.rmem_default=$RMEM_DEFAULT >/dev/null 2>&1
+	    /sbin/sysctl -w net.core.rmem_max=$RMEM_MAX >/dev/null 2>&1
+	fi
 	;;
   stop)
 	# Stop daemons.
-	[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd stop
-	echo -n $"Shutting down NFS mountd: "
+	echo -n "Shutting down NFS mountd: "
 	killproc rpc.mountd
 	echo
-	echo -n $"Shutting down NFS daemon: "
-	killproc nfsd -2
+	echo -n "Shutting down NFS daemon: "
+	killproc nfsd
 	echo
-	if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
-		echo -n $"Shutting down NFS quotas: "
+	if [ -n "$RQUOTAD" ]; then
+		echo -n "Shutting down NFS quotas: "
 		killproc rpc.rquotad
-		RETVAL=$?
 		echo
 	fi
-	# Reset the lockd ports if they were set
-	if [ -n "$LOCKD_TCPPORT" ]; then
-	    /sbin/sysctl -w fs.nfs.nlm_tcpport=0 >/dev/null 2>&1
-	fi
-	if [ -n "$LOCKD_UDPPORT" ]; then
-	    /sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1
-	fi
 	# Do it the last so that clients can still access the server
 	# when the server is running.
-	cnt=`/usr/sbin/exportfs -v | /usr/bin/wc -l`
-	if [ $cnt -gt 0 ]; then
-		action $"Shutting down NFS services: " /usr/sbin/exportfs -au
-	else
-		action $"Shutting down NFS services: " /bin/false
+	action "Shutting down NFS services: " /usr/sbin/exportfs -au
+	if [ -d /proc/fs/nfsd -a "$MOUNT_NFSD" = "yes" ] ; then
+		/bin/umount /proc/fs/nfsd
 	fi
 	rm -f /var/lock/subsys/nfs
 	;;
   status)
-	[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd status
 	status rpc.mountd
 	status nfsd
-	if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
+	if [ -n "$RQUOTAD" ]; then
 		status rpc.rquotad
 	fi
 	;;
@@ -155,28 +170,20 @@
 	;;
   probe)
 	if [ ! -f /var/lock/subsys/nfs ] ; then
-	  echo $"start"; exit 0
+	  echo start; exit 0
 	fi
 	/sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
 	/sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
 	if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then
-	  echo $"restart"; exit 0
+	  echo restart; exit 0
 	fi
 	if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
-	  echo $"reload"; exit 0
+	  echo reload; exit 0
 	fi
 	;;
-  condrestart)
-	[ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd condrestart
-  	[ -f /var/lock/subsys/nfs ] && {
-		$0 stop
-		$0 start
-	}
-	;;
   *)
-	echo $"Usage: nfs {start|stop|status|restart|reload|condrestart}"
-	RETVAL=3
-	;;
+	echo "Usage: nfs {start|stop|status|restart|reload}"
+	exit 1
 esac
 
-exit $RETVAL
+exit 0

Index: nfslock.init
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/nfs-utils.more/Attic/nfslock.init,v
retrieving revision 1.1.15.1
retrieving revision 1.1.15.2
diff -u -d -r1.1.15.1 -r1.1.15.2
--- nfslock.init	4 Jul 2010 22:42:11 -0000	1.1.15.1
+++ nfslock.init	15 Jul 2010 03:28:36 -0000	1.1.15.2
@@ -3,7 +3,7 @@
 # nfslock       This shell script takes care of starting and stopping
 #               the NFS file locking service.
 #
-# chkconfig: 345 14 86
+# chkconfig: 345 60 86
 # description: NFS is a popular protocol for file sharing across \
 #	       TCP/IP networks. This service provides NFS file \
 #	       locking functionality.
@@ -14,135 +14,77 @@
 
 # Source networking configuration.
 if [ ! -f /etc/sysconfig/network ]; then
-    exit 6
+    exit 0
 fi
 
-# Check for and source configuration file
-[ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs
-
 . /etc/sysconfig/network
 
 # Check that networking is up.
-[ "${NETWORKING}" = "no" ] && exit 6
-
-# Start lockd from userland only if kernel <= 2.2.18
-OS_RELEASE=`uname --release`
-OS_RELEASE_MAJOR=`echo "$OS_RELEASE" | sed 's/\(^[0-9]\)\..*/\1/'`
-OS_RELEASE_MINOR=`echo "$OS_RELEASE" | sed 's/\(^[0-9]\)\.\([0-9]*\)\..*/\2/'`
-OS_RELEASE_VERSION=`echo "$OS_RELEASE" | sed 's/\(^[0-9]\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'`
-
-if [ "$OS_RELEASE_MAJOR" -le 2 -a "$OS_RELEASE_MINOR" -le 2 -a "$OS_RELEASE_VERSION" -le 18 ] ; then
-    USERLAND_LOCKD="yes"
-else
-    USERLAND_LOCKD=
-fi
-
-if [ "$USERLAND_LOCKD" ] ; then
-    [ -x /sbin/rpc.lockd ] || exit 5
-fi
+[ ${NETWORKING} = "no" ] && exit 0
 
-[ -x /sbin/rpc.statd ] || exit 5 
+[ -x /sbin/rpc.lockd ] || exit 0
+[ -x /sbin/rpc.statd ] || exit 0
 
-RETVAL=0
 if [ -n "${STATD_HOSTNAME}" ]; then
     STATDARG="-n ${STATD_HOSTNAME}"
 else
     STATDARG=""
 fi
 
-
-start() {
-    if [ ! -f /var/lock/subsys/nfslock ]; then
+# See how we were called.
+case "$1" in
+  start)
 	# Start daemons.
-	if [ "$USERLAND_LOCKD" ]; then
-	  echo -n $"Starting NFS locking: "
-	  daemon rpc.lockd
-	  echo
-	else 
-	# See if the kernel lockd should start up 
-	# listening on a particular port
-	#
-		LOCKDARG=""
-		[ -n "$LOCKD_TCPPORT" ] && LOCKDARG="nlm_tcpport=$LOCKD_TCPPORT"
-		[ -n "$LOCKD_UDPPORT" ] && \
-			LOCKDARG="$LOCKDARG nlm_udpport=$LOCKD_UDPPORT"
-		[ -n "$LOCKDARG" ]  && \
-			modprobe lockd $LOCKDARG
-	fi  
-	echo -n $"Starting NFS statd: "
-	# See if a statd's ports has been defined
-	[ -n "$STATD_PORT" ] && STATDARG="$STATDARG -p $STATD_PORT"
-	[ -n "$STATD_OUTGOING_PORT" ] \
-		&& STATDARG="$STATDARG -o $STATD_OUTGOING_PORT"
-	# See if we have an HA-callout program specified
-	[ -n "$STATD_HA_CALLOUT" ] \
-		&& STATDARG="$STATDARG -H $STATD_HA_CALLOUT"
-	daemon rpc.statd "$STATDARG"
-	RETVAL=$?
+	echo "Starting NFS file locking services: "
+	echo -n "Starting NFS lockd: "
+	daemon rpc.lockd
 	echo
-	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock
-    fi
-    return $RETVAL
-}
-
-stop() {
+	echo -n "Starting NFS statd: "
+	daemon rpc.statd ${STATDARG}
+	echo
+	touch /var/lock/subsys/nfslock
+	;;
+  stop)
 	# Stop daemons.
-	if [ -n "`pidofproc lockd`" ]; then
-		echo -n $"Stopping NFS locking: "
-		killproc lockd -KILL
-		echo
+	echo "Shutting down NFS file locking services: "
+	pidlist=`pidofproc lockd`
+	if [ -n "$pidlist" ]; then
+		pid=
+		for apid in $pidlist ; do
+			[ -f /proc/$apid/exe ] && pid="$pid $apid"
+		done
+		if [ -n "$pid" ]; then
+			echo -n "Shutting down NFS lockd: "
+			killproc lockd
+			echo
+		fi
 	fi
-
-	echo -n $"Stopping NFS statd: "
+	echo -n "Shutting down NFS statd: "
 	killproc rpc.statd
-	RETVAL=$?
 	echo
 	rm -f /var/lock/subsys/nfslock
-	return $RETVAL
-}
-
-# See how we were called.
-case "$1" in
-  start)
-        start
-	;;
-  stop)
-  	stop
 	;;
   status)
-	if [ "$USERLAND_LOCKD" ]; then
-	  status lockd
-	fi 
+	status lockd
 	status rpc.statd
 	;;
   restart)
-        stop
-	start
+	$0 stop
+	$0 start
 	;;
   probe)
 	if [ ! -f /var/lock/subsys/nfslock ] ; then
-	  echo $"start"; exit 0
+	  echo start; exit 0
 	fi
 	/sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
-	if [ "$USERLAND_LOCKD" ]; then
-	   /sbin/pidof lockd >/dev/null 2>&1; LOCKD="$?"
-	else
-	   LOCKD=0
-	fi
+	/sbin/pidof lockd >/dev/null 2>&1; LOCKD="$?"
 	if [ $STATD = 1 -o $LOCKD = 1 ] ; then
-	  echo $"restart"; exit 0
+	  echo restart; exit 0
 	fi
 	;;
-  condrestart)
-  	[ -f /var/lock/subsys/nfslock ] && {
-		stop
-		start
-	}
-	;;
   *)
-	echo $"Usage: $0 {start|stop|status|restart|probe|condrestart}"
-	RETVAL=3
-	;;
+	echo "Usage: nfslock {start|stop|status|restart}"
+	exit 1
 esac
 
-exit $RETVAL
+exit 0


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first