]> git.pld-linux.org Git - packages/nfs-utils.git/blobdiff - nfs.init
- started update to 1.1.0-rc1
[packages/nfs-utils.git] / nfs.init
index e13ca8f920b89899c98c49f8f3360ef8c2be4264..62d2de781dbba46ee4e1d99237764675ce20e19c 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 12 84
 # 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
 
+[ -n "$NFSv1" ] || NFSv1="yes"
+[ -n "$NFSv2" ] || NFSv2="yes"
+[ -n "$NFSv3" ] || NFSv3="yes"
+[ -n "$NFSv4" ] || NFSv4="yes"
+
 # Check that networking is up.
 if is_yes "${NETWORKING}"; then
        if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
@@ -28,44 +34,38 @@ else
        exit 0
 fi
 
+if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then
+       [ -z "`/sbin/pidof portmap`" ] && nls "Error: portmap isn't running" && exit 0
+fi
+
 start() {
        # Check if the service is already running?
        if [ ! -f /var/lock/subsys/nfs ]; then
-               if [ -x /sbin/pidof ]; then
-                       if [ -z "`/sbin/pidof portmap`" ]; then
-                               nls "Error: portmap isn't running"
-                               exit 0
-                       fi
+               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
 
-               if ! is_yes "$NFS4" ; then
-                       RPCMOUNTOPTIONS="$RPCMOUNTOPTIONS --no-nfs-version 4"
+               # 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
+
+               for vers in 1 2 3 4 ; do
+                       is_yes $(eval echo \$NFSv$vers) || \
+                               RPCMOUNTOPTIONS="$RPCMOUNTOPTIONS --no-nfs-version $vers"
+               done
+
+               [ -n "$MOUNTD_PORT" ] && RPCMOUNTOPTIONS="$RPCMOUNTOPTIONS -p $MOUNTD_PORT"
 
                # Start daemons.
-               modprobe -s nfsd > /dev/null 2>&1
-               if [ "$(kernelverser)" -ge "002006" ]; then
-                   grep -q nfsd /proc/filesystems && \
-                   ! grep -q nfsd /proc/mounts && \
-                       run_cmd "Mounting /proc/fs/nfsd filesystem" mount -t nfsd nfsd /proc/fs/nfsd
-               fi
                msg_starting "NFS exportfs"
                daemon /usr/sbin/exportfs -r
                msg_starting "NFS mountd"
                daemon rpc.mountd $RPCMOUNTOPTIONS
-               if is_yes "$NFS4" ; then
-                   if (grep -q rpc_pipefs /proc/filesystems); then
-                       ! grep -q rpc_pipefs /proc/mounts && \
-                           run_cmd "Mounting /var/lib/nfs/rpc_pipefs filesystem" mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
-                       if [ ! -f /var/lock/subsys/idmapd ]; then
-                           msg_starting "NFS idmapd"
-                           daemon rpc.idmapd $RPCIDMAPOPTIONS
-                           [ $? = 0 ] && touch /var/lock/subsys/idmapd
-                       fi
-                       msg_starting "NFS svcgssd"
-                       daemon rpc.svcgssd $RPCSVCGSSOPTIONS
-                   fi
-               fi
                msg_starting "NFS daemon"
                daemon rpc.nfsd $RPCNFSDCOUNT
                touch /var/lock/subsys/nfs
@@ -77,21 +77,10 @@ start() {
 stop() {
        if [ -f /var/lock/subsys/nfs ]; then
                # Stop daemons.
-               msg_stopping "NFS mountd"
-               killproc rpc.mountd
                msg_stopping "NFS daemon"
                killproc nfsd -QUIT
-               if is_yes "$NFS4" ; then
-                       if (grep -q rpc_pipefs /proc/filesystems); then
-                           msg_stopping "NFS svcgssd"
-                           killproc rpc.svcgssd
-                           if [ -f /var/lock/subsys/idmapd -a ! -f /var/lock/subsys/nfsfs ]; then
-                               msg_stopping "NFS idmapd"
-                               killproc rpc.idmapd
-                               rm -f /var/lock/subsys/idmapd
-                           fi
-                       fi
-               fi
+               msg_stopping "NFS mountd"
+               killproc rpc.mountd
                msg_stopping "NFS"
                daemon /usr/sbin/exportfs -au
                rm -f /var/lock/subsys/nfs
@@ -112,14 +101,22 @@ case "$1" in
   restart)
        stop
        start
+       /sbin/service idmapd status >/dev/null && /sbin/service idmapd restart
+       /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
+               /usr/sbin/exportfs -r
                [ $? -ne 0 ] && RETVAL=7
-               [ $RETVAL -eq 0 ] && ok || died
+               if [ $RETVAL -eq 0 ]; then
+                       ok
+                       /sbin/service idmapd status >/dev/null && /sbin/service idmapd restart
+                       /sbin/service svcgssd status >/dev/null && /sbin/service svcgssd restart
+               else
+                       died
+               fi
        else
                msg_not_running "NFS"
                exit 7
@@ -142,6 +139,12 @@ case "$1" in
        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
This page took 0.040811 seconds and 4 git commands to generate.