Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 - 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 14 86
7
# description: NFS is a popular protocol for file sharing across \
8
#	       networks. This service provides NFS file locking \
9
#          functionality.
10
# probe: true
11
 
12
### BEGIN INIT INFO
13
# Provides: nfslock
14
# Required-Start: $network $syslog $rpcbind
15
# Required-Stop: $network $syslog $rpcbind
16
# Default-Start: 3 4 5
17
# Default-Stop: 0 1 6
18
# Short-Description: Start up the NFS file locking sevice
19
# Description: NFS is a popular protocol for file sharing across \
20
#          networks. This service provides NFS file locking \
21
#          functionality.
22
### END INIT INFO
23
 
24
# Source function library.
25
. /etc/rc.d/init.d/functions
26
 
27
# Source networking configuration.
28
if [ ! -f /etc/sysconfig/network ]; then
29
    exit 6
30
fi
31
 
32
# Check for and source configuration file
33
LOCKDARG=""
34
STATDARG=""
35
[ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs
36
 
37
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
38
 
39
uid=`id | cut -d\( -f1 | cut -d= -f2`
40
RETVAL=0
41
start() {
42
	# Check that networking is up.
43
	[ "${NETWORKING}" = "no" ] && exit 6
44
 
45
	[ -x /sbin/rpc.statd ] || exit 5
46
 
47
	# Only root can start the service
48
	[ $uid -ne 0 ] && exit 4
49
 
50
	# Make sure the rpc.statd is not already running.
51
	if status rpc.statd > /dev/null ; then
52
		exit 0
53
	fi
54
	rm -f /var/lock/subsys/rpc.statd
55
 
56
	# Make sure locks are recovered
57
	rm -f /var/run/sm-notify.pid
58
 
59
	# Start daemons.
60
	# See if the kernel lockd should start up
61
	# listening on a particular port
62
	#
63
	if [ -n "$LOCKD_TCPPORT" -o -n "$LOCKD_UDPPORT" ]; then
64
		[ -x /sbin/modprobe ] && /sbin/modprobe lockd $LOCKDARG
65
		[ -n "$LOCKD_TCPPORT" ] && \
66
			/sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
67
		[ -n "$LOCKD_UDPPORT" ] && \
68
			/sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
69
	fi
70
 
71
	echo -n $"Starting NFS statd: "
72
	# Set statd's local hostname if defined
73
	[ -n "${STATD_HOSTNAME}" ] && STATDARG="$STATDARG -n ${STATD_HOSTNAME}"
74
 
75
	# See if a statd's ports has been defined
76
	[ -n "$STATD_PORT" ] && STATDARG="$STATDARG -p $STATD_PORT"
77
	[ -n "$STATD_OUTGOING_PORT" ] \
78
		&& STATDARG="$STATDARG -o $STATD_OUTGOING_PORT"
79
 
80
	# See if we have an HA-callout program specified
81
	[ -n "$STATD_HA_CALLOUT" ] \
82
		&& STATDARG="$STATDARG -H $STATD_HA_CALLOUT"
83
	daemon rpc.statd "$STATDARG"
84
	RETVAL=$?
85
	echo
86
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/rpc.statd
87
    return $RETVAL
88
}
89
 
90
stop() {
91
	# Only root can stop the service
92
	[ $uid -ne 0 ] && exit 4
93
 
94
	# Stop daemons.
95
	if [ -n "`pidofproc lockd`" ]; then
96
		echo -n $"Stopping NFS locking: "
97
		killproc lockd -KILL
98
		echo
99
	fi
100
 
101
	echo -n $"Stopping NFS statd: "
102
	killproc rpc.statd
103
	RETVAL=$?
104
	echo
105
	rm -f /var/lock/subsys/rpc.statd
106
	rm -f /var/run/sm-notify.pid
107
	return $RETVAL
108
}
109
 
110
# See how we were called.
111
case "$1" in
112
  start)
113
        start
114
	;;
115
  stop)
116
  	stop
117
	;;
118
  status)
119
	status rpc.statd
120
	RETVAL=$?
121
	;;
122
  restart | force-reload | reload)
123
	stop
124
	start
125
	;;
126
  probe)
127
	if [ ! -f /var/lock/subsys/rpc.statd ] ; then
128
	  echo $"start"; exit 0
129
	fi
130
	/sbin/pidof rpc.statd >/dev/null 2>&1
131
	if [ $? = 1 ] ; then
132
	  echo $"restart"; exit 0
133
	fi
134
	;;
135
  condrestart | try-restart)
136
  	[ -f /var/lock/subsys/rpc.statd ] && {
137
		stop
138
		start
139
		RETVAL=$?
140
	}
141
	;;
142
  condstop)
143
  	[ -f /var/lock/subsys/rpc.statd ] && {
144
		stop
145
		RETVAL=$?
146
	}
147
	;;
148
  *)
149
	echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|probe|condrestart|try-restart|condstop}"
150
	RETVAL=2
151
	;;
152
esac
153
 
154
exit $RETVAL