]> git.decadent.org.uk Git - nfs-utils.git/blob - debian/nfs-common.init
2002-08-26 Chip Salzenberg <chip@pobox.com>
[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 PREFIX=
13
14 # Should rpc.statd listen on a specific port?
15 # If so, set this variable to a statd argument like: "--port 1000".
16 STATDPORT=""
17
18 NEED_LOCKD=yes
19 if test -f /proc/ksyms
20 then
21     # We need to be conservative and run lockd,
22     # unless we can prove that it isn't required.
23     grep -q lockdctl /proc/ksyms || NEED_LOCKD=no
24 fi
25
26 [ -x $PREFIX/sbin/rpc.statd ] || exit 0
27 [ -x $PREFIX/sbin/rpc.lockd ] || [ "$NEED_LOCKD" = no ] || exit 0
28
29 # What is this?
30 DESC="NFS common utilities"
31
32 # See how we were called.
33 case "$1" in
34   start)
35         cd /    # daemons should have root dir as cwd
36         printf "Starting $DESC:"
37         printf " statd"
38         start-stop-daemon --start --quiet \
39             --exec $PREFIX/sbin/rpc.statd -- $STATDPORT
40         if [ "$NEED_LOCKD" = yes ]
41         then
42             printf " lockd"
43             start-stop-daemon --start --quiet \
44                 --exec $PREFIX/sbin/rpc.lockd
45         fi
46         echo "."
47         ;;
48
49   stop)
50         printf "Stopping $DESC:"
51         if [ "$NEED_LOCKD" = yes ]
52         then
53             printf " lockd"
54             start-stop-daemon --stop --oknodo --quiet \
55                 --name rpc.lockd --user 0
56         fi
57         printf " statd"
58         start-stop-daemon --stop --oknodo --quiet \
59             --name rpc.statd --user 0
60         echo "."
61         ;;
62
63   restart | force-reload)
64         $0 stop
65         sleep 1
66         $0 start
67         ;;
68
69   *)
70         echo "Usage: nfs-common {start|stop|restart}"
71         exit 1
72         ;;
73 esac
74
75 exit 0