]> git.decadent.org.uk Git - nfs-utils.git/blob - debian/nfs-common.init
2002-10-11 H.J. Lu <hjl@lucon.org>
[nfs-utils.git] / debian / nfs-common.init
1 #!/bin/sh
2 #
3 # nfs-common    This shell script takes care of starting and stopping
4 #               common daemons required for NFS clients and servers.
5 #
6 # chkconfig: 345 20 80
7 # description: NFS is a popular protocol for file sharing across \
8 #              TCP/IP networks. This service provides NFS file \
9 #              locking functionality.
10 #
11
12 set -e
13
14 # What is this?
15 DESC="NFS common utilities"
16
17 # Read config
18 DEFAULTFILE=/etc/default/nfs-common
19 PREFIX=
20 NEED_LOCKD=
21 if [ -f $DEFAULTFILE ]; then
22     . $DEFAULTFILE
23 fi
24
25 # Determine whether lockd is required
26 case "$NEED_LOCKD" in
27 yes|no) ;;
28 *)  # We must be conservative and run lockd,
29     #  unless we can prove that it's not required.
30     NEED_LOCKD=yes
31     if test -f /proc/ksyms
32     then
33         grep -q lockdctl /proc/ksyms || NEED_LOCKD=no
34     fi
35     ;;
36 esac
37
38 # Exit if required binaries are missing.
39 [ -x $PREFIX/sbin/rpc.statd ] || exit 0
40 [ -x $PREFIX/sbin/rpc.lockd ] || [ "$NEED_LOCKD" = no ] || exit 0
41
42 # See how we were called.
43 case "$1" in
44   start)
45         cd /    # daemons should have root dir as cwd
46         printf "Starting $DESC:"
47         printf " statd"
48         start-stop-daemon --start --quiet \
49             --exec $PREFIX/sbin/rpc.statd -- $STATDOPTS
50         if [ "$NEED_LOCKD" = yes ]
51         then
52             printf " lockd"
53             start-stop-daemon --start --quiet \
54                 --exec $PREFIX/sbin/rpc.lockd  || true
55         fi
56         echo "."
57         ;;
58
59   stop)
60         printf "Stopping $DESC:"
61         if [ "$NEED_LOCKD" = yes ]
62         then
63             printf " lockd"
64             start-stop-daemon --stop --oknodo --quiet \
65                 --name rpc.lockd --user 0  || true
66         fi
67         printf " statd"
68         start-stop-daemon --stop --oknodo --quiet \
69             --name rpc.statd --user 0
70         echo "."
71         ;;
72
73   restart | force-reload)
74         $0 stop
75         sleep 1
76         $0 start
77         ;;
78
79   *)
80         echo "Usage: nfs-common {start|stop|restart}"
81         exit 1
82         ;;
83 esac
84
85 exit 0