X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=nfslock.init;h=063633466f15262f76d2825fe9a5acd086f1957e;hb=864fe5d9e78b1651cd25d10647b5a9bfa4af1197;hp=df555d7f9b491b68c559fdd8f9de3822313a095f;hpb=d39c0868f75876f1391d9c972964b0b1dd751c47;p=packages%2Fnfs-utils.git diff --git a/nfslock.init b/nfslock.init index df555d7..0636334 100644 --- a/nfslock.init +++ b/nfslock.init @@ -1,12 +1,14 @@ #!/bin/sh # # nfslock This shell script takes care of starting and stopping -# the NFS file locking service. +# the NSM status monitor - rpc.statd # -# chkconfig: 345 61 19 -# description: NFS is a popular protocol for file sharing across \ -# TCP/IP networks. This service provides NFS file \ -# locking functionality. +# chkconfig: 345 14 82 +# description: The rpc.statd server implements the NSM \ +# (Network Status Monitor) RPC protocol. \ +# It is used by the NFS file locking service, lockd \ +# to implement lock recovery when the NFS server \ +# machine crashes and reboots. # probe: true # Source function library. @@ -21,53 +23,79 @@ # Check that networking is up. if is_yes "${NETWORKING}"; then if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then - msg_network_down "NFS lockd" + msg_network_down "RPC statd" exit 1 fi else exit 0 fi -if [ -x /sbin/pidof ] && [ "$1" != "stop" ]; then - [ -z "`/sbin/pidof portmap`" ] && nls "Error: portmap isn't running" && exit 0 +if [ "$1" != "stop" ]; then + check_portmapper || { nls "Error: portmap isn't running" && exit 0; } fi -# Sanity checks +# /usr may be on NFS, fail silently, nfsfs will start it [ -x /usr/sbin/rpc.statd ] || exit 0 -RETVAL=0 -# See how we were called. -case "$1" in - start) +start() { # Check if the service is already running? if [ ! -f /var/lock/subsys/nfslock ]; then + # Set the ports lockd should listen on + if [ -n "$LOCKD_TCPPORT" ]; then + /sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1 + fi + if [ -n "$LOCKD_UDPPORT" ]; then + /sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1 + fi + + [ -n "$STATD_PORT" ] && STATDOPTS="$STATDOPTS -p $STATD_PORT" + [ -n "$STATD_OUTPORT" ] && STATDOPTS="$STATDOPTS -o $STATD_OUTPORT" + # Start daemons. - msg_starting "NFS statd" + # Don't put sm-notify here, statd will run it when started + msg_starting "RPC statd" daemon rpc.statd $STATDOPTS RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock else - msg_already_running "NFS statd" + msg_already_running "RPC statd" fi - ;; - stop) +} + +stop() { if [ -f /var/lock/subsys/nfslock ]; then + # Reset the lockd ports if they were set + if [ -n "$LOCKD_TCPPORT" ]; then + /sbin/sysctl -w fs.nfs.nlm_tcpport=0 >/dev/null 2>&1 + fi + if [ -n "$LOCKD_UDPPORT" ]; then + /sbin/sysctl -w fs.nfs.nlm_udpport=0 >/dev/null 2>&1 + fi # Stop daemons. - msg_stopping "NFS statd" + msg_stopping "RPC statd" killproc rpc.statd rm -f /var/lock/subsys/nfslock else - msg_not_running "NFS statd" + msg_not_running "RPC statd" fi +} + +RETVAL=0 +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop ;; status) status rpc.statd exit $? ;; restart|force-reload) - $0 stop - $0 start - exit $? + stop + start ;; probe) if [ ! -f /var/lock/subsys/nfslock ]; then