]> git.decadent.org.uk Git - nfs-utils.git/blob - etc/nodist/nfs-server
d95eadab78997a1ce51c0517d194a153828664ea
[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 99 01
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     if /usr/sbin/rpcinfo -u localhost nfs 3 &>/dev/null 
54     then
55         RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 3"
56     fi
57
58     # Start rquotad if it is set
59     if [ -n "$RQUOTAD" ]
60     then
61         echo -n "Starting $RQUOTAD: "
62         startdaemon $RQUOTAD
63     fi
64
65     echo -n "Starting $MOUNTD: "
66     startdaemon $MOUNTD $RPCMOUNTDOPTS
67     echo -n "Starting $NFSD: "
68     startdaemon $PREFIX$NFSD $RPCNFSDCOUNT
69
70     # if this lock file doesn't exist, init won't even try to run
71     # the shutdown script for this service on RedHat systems!
72     # on non-RedHat systems, /var/lock/subsys may not exist.
73     touch /var/lock/subsys/$SCRIPT_NAME &> /dev/null
74     ;;
75
76 stop)
77     for process in $RQUOTAD $MOUNTD $NFSD
78     do
79         echo -n "Stopping $process: "
80         stopdaemon $process
81     done
82
83     echo "Unexporting directories for $DESC..."
84     $EXPORTFS -au
85     rm -f /var/lock/subsys/$SCRIPT_NAME 
86     echo "done."
87     ;;
88
89 restart)
90     $0 stop
91     $0 start
92     ;;
93
94 reload)
95     # Update exports
96     echo "Re-exporting directories for $DESC..."
97     $EXPORTFS -r
98     touch /var/lock/subsys/$SCRIPT_NAME &> /dev/null
99     echo "done."
100     ;;
101
102 status)
103     # First, check status of userland daemons
104     for process in $RQUOTAD $MOUNTD $NFSD
105     do
106         daemonstatus $process
107     done
108     exit 0
109     ;;
110
111 *)
112     echo "Usage: $0 {start|stop|status|restart|reload}"
113     exit 1
114 esac