Blame | Last modification | View Log | RSS feed
#!/bin/sh## nfslock This shell script takes care of starting and stopping# the NFS file locking service.## chkconfig: 345 14 86# description: NFS is a popular protocol for file sharing across \# networks. This service provides NFS file locking \# functionality.# probe: true### BEGIN INIT INFO# Provides: nfslock# Required-Start: $network $syslog $rpcbind# Required-Stop: $network $syslog $rpcbind# Default-Start: 3 4 5# Default-Stop: 0 1 6# Short-Description: Start up the NFS file locking sevice# Description: NFS is a popular protocol for file sharing across \# networks. This service provides NFS file locking \# functionality.### END INIT INFO# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.if [ ! -f /etc/sysconfig/network ]; thenexit 6fi# Check for and source configuration fileLOCKDARG=""STATDARG=""[ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs[ -f /etc/sysconfig/network ] && . /etc/sysconfig/networkuid=`id | cut -d\( -f1 | cut -d= -f2`RETVAL=0start() {# Check that networking is up.[ "${NETWORKING}" = "no" ] && exit 6[ -x /sbin/rpc.statd ] || exit 5# Only root can start the service[ $uid -ne 0 ] && exit 4# Make sure the rpc.statd is not already running.if status rpc.statd > /dev/null ; thenexit 0firm -f /var/lock/subsys/rpc.statd# Make sure locks are recoveredrm -f /var/run/sm-notify.pid# Start daemons.# See if the kernel lockd should start up# listening on a particular port#if [ -n "$LOCKD_TCPPORT" -o -n "$LOCKD_UDPPORT" ]; then[ -x /sbin/modprobe ] && /sbin/modprobe lockd $LOCKDARG[ -n "$LOCKD_TCPPORT" ] && \/sbin/sysctl -w fs.nfs.nlm_tcpport=$LOCKD_TCPPORT >/dev/null 2>&1[ -n "$LOCKD_UDPPORT" ] && \/sbin/sysctl -w fs.nfs.nlm_udpport=$LOCKD_UDPPORT >/dev/null 2>&1fiecho -n $"Starting NFS statd: "# Set statd's local hostname if defined[ -n "${STATD_HOSTNAME}" ] && STATDARG="$STATDARG -n ${STATD_HOSTNAME}"# See if a statd's ports has been defined[ -n "$STATD_PORT" ] && STATDARG="$STATDARG -p $STATD_PORT"[ -n "$STATD_OUTGOING_PORT" ] \&& STATDARG="$STATDARG -o $STATD_OUTGOING_PORT"# See if we have an HA-callout program specified[ -n "$STATD_HA_CALLOUT" ] \&& STATDARG="$STATDARG -H $STATD_HA_CALLOUT"daemon rpc.statd "$STATDARG"RETVAL=$?echo[ $RETVAL -eq 0 ] && touch /var/lock/subsys/rpc.statdreturn $RETVAL}stop() {# Only root can stop the service[ $uid -ne 0 ] && exit 4# Stop daemons.if [ -n "`pidofproc lockd`" ]; thenecho -n $"Stopping NFS locking: "killproc lockd -KILLechofiecho -n $"Stopping NFS statd: "killproc rpc.statdRETVAL=$?echorm -f /var/lock/subsys/rpc.statdrm -f /var/run/sm-notify.pidreturn $RETVAL}# See how we were called.case "$1" instart)start;;stop)stop;;status)status rpc.statdRETVAL=$?;;restart | force-reload | reload)stopstart;;probe)if [ ! -f /var/lock/subsys/rpc.statd ] ; thenecho $"start"; exit 0fi/sbin/pidof rpc.statd >/dev/null 2>&1if [ $? = 1 ] ; thenecho $"restart"; exit 0fi;;condrestart | try-restart)[ -f /var/lock/subsys/rpc.statd ] && {stopstartRETVAL=$?};;condstop)[ -f /var/lock/subsys/rpc.statd ] && {stopRETVAL=$?};;*)echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|probe|condrestart|try-restart|condstop}"RETVAL=2;;esacexit $RETVAL