summaryrefslogtreecommitdiffstats
path: root/etc/redhat/nfslock.init
blob: 3225b3a560985176a4c7e3a962a24faa00dbf051 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh
#
# nfslock       This shell script takes care of starting and stopping
#               the NFS file locking service.
#
# chkconfig: 345 60 20
# description: NFS is a popular protocol for file sharing across \
#	       TCP/IP networks. This service provides NFS file \
#	       locking functionality.
# probe: true

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
if [ ! -f /etc/sysconfig/network ]; then
    exit 0
fi

. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -x /sbin/rpc.lockd ] || exit 0
[ -x /sbin/rpc.statd ] || exit 0

# See how we were called.
case "$1" in
  start)
	# Start daemons.
	echo "Starting NFS file locking services: "
	echo -n "Starting NFS lockd: "
	daemon rpc.lockd
	echo
	echo -n "Starting NFS statd: "
	daemon rpc.statd
	echo
	touch /var/lock/subsys/nfslock
	;;
  stop)
	# Stop daemons.
	echo "Shutting down NFS file locking services: "
	pidlist=`pidofproc lockd`
	if [ -n "$pidlist" ]; then
		pid=
		for apid in $pidlist ; do
			[ -f /proc/$apid/exe ] && pid="$pid $apid"
		done
		if [ -n "$pid" ]; then
			echo -n "Shutting down NFS lockd: "
			killproc lockd
			echo
		fi
	fi
	echo -n "Shutting down NFS statd: "
	killproc rpc.statd
	echo
	rm -f /var/lock/subsys/nfslock
	;;
  status)
	status lockd
	status rpc.statd
	;;
  restart)
	echo -n "Restarting NFS file locking services: "
	echo -n "rpc.lockd "
	killproc lockd
	daemon rpc.lockd
	echo -n "rpc.statd "
	killproc rpc.statd
	daemon rpc.statd
	touch /var/lock/subsys/nfslock
	echo "done."
	;;
  probe)
	if [ ! -f /var/lock/subsys/nfslock ] ; then
	  echo start; exit 0
	fi
	/sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
	/sbin/pidof lockd >/dev/null 2>&1; LOCKD="$?"
	if [ $STATD = 1 -o $LOCKD = 1 ] ; then
	  echo restart; exit 0
	fi
	;;
  *)
	echo "Usage: nfslock {start|stop|status|restart}"
	exit 1
esac

exit 0