]> git.pld-linux.org Git - packages/nfs-utils.git/blobdiff - nfslock.init
- statd is needed only for NFSv2 or NFSv3
[packages/nfs-utils.git] / nfslock.init
index f2352f508c9bf07525098370c70445f10384d03d..49c9d6e77661f7cc16789932c99eea10ae65b83c 100644 (file)
@@ -1,13 +1,13 @@
 #!/bin/sh
 #
-# nfslock       This shell script takes care of starting and stopping
-#               the NFS file locking service.
+# nfslock      This shell script takes care of starting and stopping
+#              the NFS file locking service.
 #
-# chkconfig:   345 61 19
+# chkconfig:   345 14 81
 # description: NFS is a popular protocol for file sharing across \
 #              TCP/IP networks. This service provides NFS file \
 #              locking functionality.
-# probe: true
+# probe:       true
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 [ -f /etc/sysconfig/nfslock ] && . /etc/sysconfig/nfslock
 
 # Check that networking is up.
-if is_no "${NETWORKING}"; then
-       msg_Network_Down "NFS lockd"
-       exit 1
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down "NFS lockd"
+               exit 1
+       fi
+else
+       exit 0
 fi
 
 if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then
-       [ -z "`/sbin/pidof portmap`" ] && echo "Error: portmap isn't running" && exit 0
+       [ -z "`/sbin/pidof portmap`" ] && nls "Error: portmap isn't running" && exit 0
 fi
 
-# Sanity checks
+# /usr may be on NFS, fail silently, nfsfs will start it
 [ -x /usr/sbin/rpc.statd ] || exit 0
 
+start() {
+       # Check if the service is already running?
+       if [ ! -f /var/lock/subsys/nfslock ]; then
+               # 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
+               fi
+               if [ -n "$LOCKD_UDPPORT" ]; then
+                       /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
+               fi
+
+               [ -n "$STATD_PORT" ] && STATDOPTS="$STATDOPTS -p $STATD_PORT"
+               [ -n "$STATD_OUTPORT" ] && STATDOPTS="$STATDOPTS -o $STATD_OUTPORT"
+
+               # Start daemons.
+               if is_yes "$NFSv2" || is_yes "$NFSv3" ; then
+                       msg_starting "NFS statd"
+                       daemon rpc.statd $STATDOPTS
+                       RETVAL=$?
+                       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock
+               else
+                       touch /var/lock/subsys/nfslock
+               fi
+       else
+               msg_already_running "NFS statd"
+       fi
+}
+
+stop() {
+       if [ -f /var/lock/subsys/nfslock ]; then
+               # 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
+               # Stop daemons.
+               if is_yes "$NFSv2" || is_yes "$NFSv3" ; then
+                       msg_stopping "NFS statd"
+                       killproc rpc.statd
+               fi
+               rm -f /var/lock/subsys/nfslock
+       else
+               msg_not_running "NFS statd"
+       fi
+}
+
+RETVAL=0
 # See how we were called.
 case "$1" in
   start)
-       # Start daemons.
-       msg_starting "NFS statd"
-       daemon rpc.statd
-       touch /var/lock/subsys/nfslock
+       start
        ;;
   stop)
-       # Stop daemons.
-       msg_stopping "NFS statd"
-       killproc rpc.statd
-       rm -f /var/lock/subsys/nfslock
+       stop
        ;;
   status)
-       status rpc.statd
+       if is_yes "$NFSv2" || is_yes "$NFSv3" ; then
+               status rpc.statd
+               exit $?
+       else
+               echo "NFSv2 and NFSv3 disabled"
+               exit 0
+       fi
        ;;
-  restart)
-       $0 stop
-       $0 start
+  restart|force-reload)
+       stop
+       start
        ;;
   probe)
-       if [ ! -f /var/lock/subsys/nfslock ] ; then
-         echo start; exit 0
+       if [ ! -f /var/lock/subsys/nfslock ]; then
+               echo start
+               exit 0
        fi
-       /sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
-       if [ $STATD = 1 ] ; then
-         echo restart; exit 0
+       if is_yes "$NFSv2" || is_yes "$NFSv3" ; then
+               /sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
+               if [ $STATD = 1 ]; then
+                       echo restart
+                       exit 0
+               fi
+       else
+               exit 0
        fi
        ;;
   *)
-       msg_Usage "$0 {start|stop|status|restart}"
-       exit 1
+       msg_usage "$0 {start|stop|restart|force-reload|probe|status}"
+       exit 3
 esac
 
-exit 0
+exit $RETVAL
This page took 0.029975 seconds and 4 git commands to generate.