]> git.decadent.org.uk Git - nfs-utils.git/blob - etc/redhat/nfslock.init
1442637816a34ece25f596b3f9e51b943168ec99
[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 20
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 /usr/sbin/rpc.lockd ] || exit 0
26 [ -x /usr/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         echo -n "Shutting down NFS lockd: "
45         killproc lockd
46         echo
47         echo -n "Shutting down NFS statd: "
48         killproc rpc.statd
49         echo
50         rm -f /var/lock/subsys/nfslock
51         ;;
52   status)
53         status lockd
54         status rpc.statd
55         ;;
56   restart)
57         echo -n "Restarting NFS file locking services: "
58         echo -n "rpc.lockd "
59         killproc lockd
60         daemon rpc.lockd
61         echo -n "rpc.statd "
62         killproc rpc.statd
63         daemon rpc.statd
64         touch /var/lock/subsys/nfslock
65         echo "done."
66         ;;
67   probe)
68         if [ ! -f /var/lock/subsys/nfslock ] ; then
69           echo start; exit 0
70         fi
71         /sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
72         /sbin/pidof lockd >/dev/null 2>&1; LOCKD="$?"
73         if [ $STATD = 1 -o $LOCKD = 1 ] ; then
74           echo restart; exit 0
75         fi
76         ;;
77   *)
78         echo "Usage: nfslock {start|stop|status|restart}"
79         exit 1
80 esac
81
82 exit 0