3 # nfslock This shell script takes care of starting and stopping
4 # the NFS file locking service.
7 # description: NFS is a popular protocol for file sharing across \
8 # TCP/IP networks. This service provides NFS file \
9 # locking functionality.
12 # Source function library.
13 . /etc/rc.d/init.d/functions
16 . /etc/sysconfig/network
19 [ -f /etc/sysconfig/nfslock ] && . /etc/sysconfig/nfslock
21 # Check that networking is up.
22 if is_yes "${NETWORKING}"; then
23 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
24 msg_network_down "NFS statd"
31 if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then
32 [ -z "`/sbin/pidof portmap`" ] && nls "Error: portmap isn't running" && exit 0
35 # /usr may be on NFS, fail silently, nfsfs will start it
36 [ -x /usr/sbin/rpc.statd ] || exit 0
39 # Check if the service is already running?
40 if [ ! -f /var/lock/subsys/nfslock ]; then
41 # Set the ports lockd should listen on
42 if [ -n "$LOCKD_TCPPORT" ]; then
43 /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1
45 if [ -n "$LOCKD_UDPPORT" ]; then
46 /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1
49 [ -n "$STATD_PORT" ] && STATDOPTS="$STATDOPTS -p $STATD_PORT"
50 [ -n "$STATD_OUTPORT" ] && STATDOPTS="$STATDOPTS -o $STATD_OUTPORT"
53 # Don't put sm-notify here, statd will run it when started
54 msg_starting "NFS statd"
55 daemon rpc.statd $STATDOPTS
57 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock
59 msg_already_running "NFS statd"
64 if [ -f /var/lock/subsys/nfslock ]; then
65 # Reset the lockd ports if they were set
66 if [ -n "$LOCKD_TCPPORT" ]; then
67 /sbin/sysctl -w fs.nfs.nlm_tcpport=0 >/dev/null 2>&1
69 if [ -n "$LOCKD_UDPPORT" ]; then
70 /sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1
73 msg_stopping "NFS statd"
75 rm -f /var/lock/subsys/nfslock
77 msg_not_running "NFS statd"
82 # See how we were called.
99 if [ ! -f /var/lock/subsys/nfslock ]; then
103 /sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
104 if [ $STATD = 1 ]; then
110 msg_usage "$0 {start|stop|restart|force-reload|probe|status}"