]> git.decadent.org.uk Git - nfs-utils.git/blob - debian/nfs-common.init
Merge commit 'debian/1.0.7-2'
[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 daemon is required.
26 case "$NEED_LOCKD" in
27 yes|no) ;;
28 *)  case `uname -r` in
29     '' | [01].* | 2.[0123].* )
30         # Older kernels may or may not need a lockd daemon.
31         # We must assume they do, unless we can prove otherwise.
32         # (A false positive here results only in a harmless message.)
33         NEED_LOCKD=yes
34         if test -f /proc/ksyms
35         then
36             grep -q lockdctl /proc/ksyms || NEED_LOCKD=no
37         fi
38         ;;
39
40     *)  # Modern kernels (>= 2.4) start a lockd thread automatically.
41         NEED_LOCKD=no
42         ;;
43     esac
44     ;;
45 esac
46
47 # Exit if required binaries are missing.
48 [ -x $PREFIX/sbin/rpc.statd ] || exit 0
49 [ -x $PREFIX/sbin/rpc.lockd ] || [ "$NEED_LOCKD" = no ] || exit 0
50
51 # See how we were called.
52 case "$1" in
53   start)
54         cd /    # daemons should have root dir as cwd
55         printf "Starting $DESC:"
56         printf " statd"
57         start-stop-daemon --start --quiet \
58             --exec $PREFIX/sbin/rpc.statd -- $STATDOPTS
59         if [ "$NEED_LOCKD" = yes ]
60         then
61             printf " lockd"
62             start-stop-daemon --start --quiet \
63                 --exec $PREFIX/sbin/rpc.lockd  || true
64         fi
65         echo "."
66         ;;
67
68   stop)
69         printf "Stopping $DESC:"
70         if [ "$NEED_LOCKD" = yes ]
71         then
72             printf " lockd"
73             start-stop-daemon --stop --oknodo --quiet \
74                 --name rpc.lockd --user 0  || true
75         fi
76         printf " statd"
77         start-stop-daemon --stop --oknodo --quiet \
78             --name rpc.statd --user 0
79         echo "."
80         ;;
81
82   restart | force-reload)
83         $0 stop
84         sleep 1
85         $0 start
86         ;;
87
88   *)
89         echo "Usage: nfs-common {start|stop|restart}"
90         exit 1
91         ;;
92 esac
93
94 exit 0