401c61445dd5238ba10bf01879ded1d7c0c5ab70
[nfs-utils.git] / etc / redhat / nfslock.init
1 #!/bin/sh
2 #
3 # nfslock       This shell script takes care of starting and stopping
4 #               the NFS file locking service.
5 #
6 # chkconfig: 345 60 86
7 # description: NFS is a popular protocol for file sharing across \
8 #              TCP/IP networks. This service provides NFS file \
9 #              locking functionality.
10 # probe: true
11
12 # Source function library.
13 . /etc/rc.d/init.d/functions
14
15 # Source networking configuration.
16 if [ ! -f /etc/sysconfig/network ]; then
17     exit 0
18 fi
19
20 . /etc/sysconfig/network
21
22 # Check that networking is up.
23 [ ${NETWORKING} = "no" ] && exit 0
24
25 [ -x /sbin/rpc.lockd ] || exit 0
26 [ -x /sbin/rpc.statd ] || exit 0
27
28 # See how we were called.
29 case "$1" in
30   start)
31         # Start daemons.
32         echo "Starting NFS file locking services: "
33         echo -n "Starting NFS lockd: "
34         daemon rpc.lockd
35         echo
36         echo -n "Starting NFS statd: "
37         daemon rpc.statd
38         echo
39         touch /var/lock/subsys/nfslock
40         ;;
41   stop)
42         # Stop daemons.
43         echo "Shutting down NFS file locking services: "
44         pidlist=`pidofproc lockd`
45         if [ -n "$pidlist" ]; then
46                 pid=
47                 for apid in $pidlist ; do
48                         [ -f /proc/$apid/exe ] && pid="$pid $apid"
49                 done
50                 if [ -n "$pid" ]; then
51                         echo -n "Shutting down NFS lockd: "
52                         killproc lockd
53                         echo
54                 fi
55         fi
56         echo -n "Shutting down NFS statd: "
57         killproc rpc.statd
58         echo
59         rm -f /var/lock/subsys/nfslock
60         ;;
61   status)
62         status lockd
63         status rpc.statd
64         ;;
65   restart)
66         echo -n "Restarting NFS file locking services: "
67         echo -n "rpc.lockd "
68         killproc lockd
69         daemon rpc.lockd
70         echo -n "rpc.statd "
71         killproc rpc.statd
72         daemon rpc.statd
73         touch /var/lock/subsys/nfslock
74         echo "done."
75         ;;
76   probe)
77         if [ ! -f /var/lock/subsys/nfslock ] ; then
78           echo start; exit 0
79         fi
80         /sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
81         /sbin/pidof lockd >/dev/null 2>&1; LOCKD="$?"
82         if [ $STATD = 1 -o $LOCKD = 1 ] ; then
83           echo restart; exit 0
84         fi
85         ;;
86   *)
87         echo "Usage: nfslock {start|stop|status|restart}"
88         exit 1
89 esac
90
91 exit 0