]> git.decadent.org.uk Git - nfs-utils.git/blob - debian/nfs-common.init
Debian build support.
[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 NEED_LOCKD=yes
15 if test -f /proc/ksyms
16 then
17     # We need to be conservative and run lockd,
18     # unless we can prove that it isn't required.
19     grep -q lockdctl /proc/ksyms || NEED_LOCKD=no
20 fi
21
22 [ -x $PREFIX/sbin/rpc.statd ] || exit 0
23 [ -x $PREFIX/sbin/rpc.lockd ] || [ "$NEED_LOCKD" = no ] || exit 0
24
25 # What is this?
26 DESC="NFS common utilities"
27
28 # Make sure that daemon cwds are in root fs.
29 cd /
30
31 # See how we were called.
32 case "$1" in
33   start)
34         printf "Starting $DESC:"
35         printf " statd"
36         start-stop-daemon --start --quiet \
37             --exec $PREFIX/sbin/rpc.statd
38         if [ "$NEED_LOCKD" = yes ]
39         then
40             printf " lockd"
41             start-stop-daemon --start --quiet \
42                 --exec $PREFIX/sbin/rpc.lockd
43         fi
44         echo "."
45         ;;
46
47   stop)
48         printf "Stopping $DESC:"
49         if [ "$NEED_LOCKD" = yes ]
50         then
51             printf " lockd"
52             start-stop-daemon --stop --oknodo --quiet \
53                 --name lockd --user root --signal 9
54         fi
55         printf " statd"
56         start-stop-daemon --stop --oknodo --quiet \
57             --exec $PREFIX/sbin/rpc.statd
58         echo "."
59         ;;
60
61   restart | force-reload)
62         $0 stop
63         sleep 1
64         $0 start
65         ;;
66
67   *)
68         echo "Usage: nfs-common {start|stop|restart}"
69         exit 1
70         ;;
71 esac
72
73 exit 0