]> git.decadent.org.uk Git - nfs-utils.git/blob - etc/nodist/nfs-server
auth_reload calls in cache.
[nfs-utils.git] / etc / nodist / nfs-server
1 #!/bin/sh
2 # nfs   This shell script starts and stops the nfs services in a distribution
3 #       independent fashion.
4 #
5 # description:  starts and stops nfs server services
6 # chkconfig: 2345 60 20
7 #
8 # Copyright (c) 2000-2001 Mission Critical Linux, Inc.
9 #
10
11 PATH=/sbin:/bin:/usr/sbin:/usr/bin
12 export PATH
13
14 # Who am I?
15 SCRIPT_NAME=`basename $0`
16
17 # Grab our daemon functions.
18 . `dirname $0`/nfs-functions
19
20 # Kernel daemons and options
21 PREFIX="rpc."           # Prefix for kernel execs (usually "rpc.")
22 NFSD="nfsd"             # Kernel NFS Server
23 RPCNFSDCOUNT="8"        # Number of nfsd threads
24
25 # User daemons and options
26 RQUOTAD="rpc.rquotad"   # Remote quota server
27 MOUNTD="rpc.mountd"     # Mount server
28 RPCMOUNTDOPTS=""        # options for rpc.mountd
29 EXPORTFS="exportfs"     # Exportfs command
30
31 SCRIPT_NAME=`basename $0`
32 DESC="NFS kernel daemon"
33
34 # We use "type -path" instead of "which" since it's internal to bash.
35 [ -x "`type -path $PREFIX$NFSD`" ] || exit 0
36 [ -x "`type -path $MOUNTD`" ] || exit 0
37
38 # Also make sure we have our exportfs command.
39 [ -x "`type -path $EXPORTFS`" ] || exit 0
40 [ -s /etc/exports ] || exit 0
41
42 # rquotad is not required for NFS to work, however.
43 # Unset if it is not present.
44 [ -x "`type -path $RQUOTAD`" ] || unset RQUOTAD
45
46 # Handle how we were called.
47 case "$1" in
48 start)
49     echo -n "Exporting directories for $DESC..."
50     $EXPORTFS -r
51     echo "done."
52
53     echo -n "Starting $NFSD: "
54     startdaemon $PREFIX$NFSD $RPCNFSDCOUNT
55
56     # Disable NFSv3 on mountd if we don't have NFSv3
57     ClearAddr=
58     if [ -f /proc/net/rpc/auth.unix.ip/channel ] ; then
59       if   grep -s 127.0.0.1 /proc/net/rpc/auth.unix.ip/content > /dev/null ; then
60              : address already known
61       else
62              echo nfsd 127.0.0.1 2147483647 localhost > /proc/net/rpc/auth.unix.ip/channel
63              ClearAddr=
64       fi
65     fi
66     rpcinfo -u localhost nfs 3 &>/dev/null 
67     if [ "$?" != "0" ]
68     then
69         RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 3"
70     fi
71     if [ -n "$ClearAddr" ]; then
72           echo nfsd 127.0.0.1 1  > /proc/net/rpc/auth.unix.ip/channel
73     fi
74
75     echo -n "Starting $MOUNTD: "
76     startdaemon $MOUNTD $RPCMOUNTDOPTS
77
78     # Start rquotad if it is set
79     if [ -n "$RQUOTAD" ]
80     then
81         echo -n "Starting $RQUOTAD: "
82         startdaemon $RQUOTAD
83     fi
84
85     # if this lock file doesn't exist, init won't even try to run
86     # the shutdown script for this service on RedHat systems!
87     # on non-RedHat systems, /var/lock/subsys may not exist.
88     touch /var/lock/subsys/$SCRIPT_NAME &> /dev/null
89     ;;
90
91 stop)
92     for process in $RQUOTAD $MOUNTD $NFSD
93     do
94         echo -n "Stopping $process: "
95         stopdaemon $process
96     done
97
98     echo "Unexporting directories for $DESC..."
99     $EXPORTFS -au
100     rm -f /var/lock/subsys/$SCRIPT_NAME 
101     echo "done."
102     ;;
103
104 restart)
105     $0 stop
106     $0 start
107     ;;
108
109 reload)
110     # Update exports
111     echo "Re-exporting directories for $DESC..."
112     $EXPORTFS -r
113     touch /var/lock/subsys/$SCRIPT_NAME &> /dev/null
114     echo "done."
115     ;;
116
117 status)
118     # First, check status of userland daemons
119     for process in $RQUOTAD $MOUNTD $NFSD
120     do
121         daemonstatus $process
122     done
123     exit 0
124     ;;
125
126 *)
127     echo "Usage: $0 {start|stop|status|restart|reload}"
128     exit 1
129 esac