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 lockd"
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 if is_yes "$NFSv2" || is_yes "$NFSv3" ; then
54 msg_starting "NFS statd"
55 daemon rpc.statd $STATDOPTS
57 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock
59 touch /var/lock/subsys/nfslock
62 msg_already_running "NFS statd"
67 if [ -f /var/lock/subsys/nfslock ]; then
68 # Reset the lockd ports if they were set
69 if [ -n "$LOCKD_TCPPORT" ]; then
70 /sbin/sysctl -w fs.nfs.nlm_tcpport=0 >/dev/null 2>&1
72 if [ -n "$LOCKD_UDPPORT" ]; then
73 /sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1
76 if is_yes "$NFSv2" || is_yes "$NFSv3" ; then
77 msg_stopping "NFS statd"
80 rm -f /var/lock/subsys/nfslock
82 msg_not_running "NFS statd"
87 # See how we were called.
96 if is_yes "$NFSv2" || is_yes "$NFSv3" ; then
100 echo "NFSv2 and NFSv3 disabled"
104 restart|force-reload)
109 if [ ! -f /var/lock/subsys/nfslock ]; then
113 if is_yes "$NFSv2" || is_yes "$NFSv3" ; then
114 /sbin/pidof rpc.statd >/dev/null 2>&1; STATD="$?"
115 if [ $STATD = 1 ]; then
124 msg_usage "$0 {start|stop|restart|force-reload|probe|status}"