]> git.pld-linux.org Git - packages/nfs-utils.git/blobdiff - nfs.init
- updated to 2.3.4
[packages/nfs-utils.git] / nfs.init
index 91c4be8c8d5b26c85b433912b58f8d3e4392e0ee..e3019b211b31db5f3cc89e443276b7085488b799 100644 (file)
--- a/nfs.init
+++ b/nfs.init
@@ -3,7 +3,7 @@
 # nfs          This shell script takes care of starting and stopping
 #              the NFS services.
 #
-# chkconfig:   345 60 20
+# chkconfig:   345 13 81
 # description: NFS is a popular protocol for file sharing across TCP/IP \
 #              networks. This service provides NFS server functionality, \
 #              which is configured via the /etc/exports file.
 # Get network config
 . /etc/sysconfig/network
 
-# Get service config
+# Get service configs
+[ -f /etc/sysconfig/nfslock ] && . /etc/sysconfig/nfslock
 [ -f /etc/sysconfig/nfsd ] && . /etc/sysconfig/nfsd
 
 # Check that networking is up.
-if [ "${NETWORKING}" = "no" ]; then
-       echo "WARNING: Networking is down. Knfsd can't be run"
-       exit 1
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down "NFS daemon"
+               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
+if [ "$1" != "stop" ]; then
+       check_portmapper || { nls "Error: portmap isn't running" && exit 0; }
 fi
 
-# Sanity checks
-[ -x /usr/sbin/rpc.nfsd ] || exit 0
-[ -x /usr/sbin/rpc.mountd ] || exit 0
-[ -f /etc/exports ] || exit 0
+start() {
+       # Check if the service is already running?
+       if [ -f /var/lock/subsys/nfs ]; then
+               msg_already_running "NFS daemon"
+               return
+       fi
 
-# See how we were called.
-case "$1" in
-  start)
-       # Start daemons.
-       if [ "$NFSDTYPE" = "U" ] ; then
-               show "Starting NFS mountd"
-               daemon rpc.mountd
-               show "Starting NFS daemon"
-               daemon rpc.nfsd
-       else
-               show "Starting NFS services"
-               daemon /usr/sbin/exportfs -r
-               show "Starting NFS mountd"
-               daemon rpc.mountd $RPCMOUNTDOPTS
-               show "Starting NFS daemon"
-               daemon rpc.nfsd $RPCNFSDCOUNT
+       if ! grep -q nfsd /proc/mounts ; then
+               modprobe -s nfsd > /dev/null 2>&1
+               run_cmd "Mounting /proc/fs/nfsd filesystem" mount -t nfsd nfsd /proc/fs/nfsd
+       fi
+
+       # 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
+
+       # Start daemons.
+       msg_starting "NFS exportfs"
+       daemon /usr/sbin/exportfs -r
+       msg_starting "NFS mountd"
+       daemon /usr/sbin/rpc.mountd $RPCMOUNTDOPTIONS
+       msg_starting "NFS daemon"
+       daemon /usr/sbin/rpc.nfsd $RPCNFSDCOUNT
        touch /var/lock/subsys/nfs
-       ;;
-  stop)
-       # Stop daemons.
-       if [ "$NFSDTYPE" = "U" ] ; then
-               show "Shutting down NFS mountd"
-               killproc rpc.mountd
-               show "Shutting down NFS daemon"
-               killproc rpc.nfsd
-       else
-               show "Shutting down NFS services"
-               daemon /usr/sbin/exportfs -au
-               show "Shutting down NFS mountd"
-               killproc rpc.mountd
-               show "Shutting down NFS daemon"
-               killproc nfsd -QUIT
+}
+
+stop() {
+       if [ ! -f /var/lock/subsys/nfs ]; then
+               msg_not_running "NFS"
+               return
        fi
+
+       # Stop daemons.
+       msg_stopping "NFS daemon"
+       killproc nfsd -QUIT
+       msg_stopping "NFS mountd"
+       killproc rpc.mountd
+       msg_stopping "NFS exportfs"
+       daemon /usr/sbin/exportfs -au
        rm -f /var/lock/subsys/nfs
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
        ;;
-  status)
-       status rpc.mountd
-       if [ "$NFSDTYPE" = "U" ] ; then
-               status rpc.nfsd
-       else
-               status nfsd
-       fi
+  stop)
+       stop
        ;;
   restart)
-       if [ "$NFSDTYPE" = "U" ] ; then
-               $0 stop
-               $0 start
-       else
-               show "Restarting NFS services (killing)"
-               killproc rpc.mountd
-               show "Restarting NFS services (starting)"
-               daemon rpc.mountd $RPCMOUNTDOPTS
+       stop
+       start
+       /sbin/service idmapd status >/dev/null && /sbin/service idmapd reload
+       /sbin/service svcgssd status >/dev/null && /sbin/service svcgssd restart
+       ;;
+  reload|force-reload)
+       if [ -f /var/lock/subsys/nfs ]; then
+               msg_reloading "NFS"
+               busy
                /usr/sbin/exportfs -r
-               touch /var/lock/subsys/nfs
+               [ $? -ne 0 ] && RETVAL=7
+               if [ $RETVAL -eq 0 ]; then
+                       ok
+                       /sbin/service idmapd status >/dev/null && /sbin/service idmapd reload
+                       /sbin/service svcgssd status >/dev/null && /sbin/service svcgssd restart
+               else
+                       died
+               fi
+       else
+               msg_not_running "NFS"
+               exit 7
        fi
        ;;
-  reload)
-       [ "$NFSDTYPE" = "U" ] && exit 0
-       /usr/sbin/exportfs
-       touch /var/lock/subsys/nfs
-       ;;
   probe)
-       [ "$NFSDTYPE" = "U" ] && exit 0
-       if [ ! -f /var/lock/subsys/nfs ] ; then
-         echo start; exit 0
+       if [ ! -f /var/lock/subsys/nfs ]; then
+               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
+       if [ $MOUNTD = 1 -o $NFSD = 1 ]; then
+               echo restart
+               exit 0
        fi
-       if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
-         echo reload; exit 0
+       if [ /etc/exports -nt /var/lock/subsys/nfs ]; then
+               echo reload
+               exit 0
        fi
        ;;
+  status)
+       echo "Configured NFS exports:"
+       grep -v "^#" /etc/exports
+       echo
+       echo "Active NFS exports:"
+       /usr/sbin/exportfs -v
+       echo
+       status rpc.mountd
+       RETVAL=$?
+       status nfsd
+       RET=$?
+       [ $RETVAL -eq 0 ] && RETVAL=$RET
+       ;;
   *)
-       echo "Usage: nfs {start|stop|status|restart|reload|probe}"
-       exit 1
+       msg_usage "$0 {start|stop|restart|reload|force-reload|probe|status}"
+       exit 3
 esac
 
-exit 0
+exit $RETVAL
This page took 0.046572 seconds and 4 git commands to generate.