#!/bin/sh -p
# nfsmount calls this script when mounting a filesystem with locking
# enabled, but when statd does not seem to be running (based on
# /var/run/rpc.statd.pid).
# It should run run statd with whatever flags are apropriate for this
# site.
PATH=/sbin:/usr/sbin:/bin:/usr/bin
. /etc/sysconfig/nfs
[ -n "$STATD_HOSTNAME" ]       && STATD_OPTIONS="$STATD_OPTIONS -n $STATD_HOSTNAME"
[ -n "$STATD_PORT" ]           && STATD_OPTIONS="$STATD_OPTIONS -p $STATD_PORT"
if [ -s /var/run/rpc.statd.pid ] &&
       [ `cat /var/run/rpc.statd.pid` -gt 1 ] &&
       kill -0 `cat /var/run/rpc.statd.pid` > /dev/null 2>&1
then
    # statd already running - must have been slow to respond.
    exit 0
fi

cd /
rpc.statd --no-notify $STATD_OPTIONS; st=$?
if [ $st -eq 0 ];
then
   # in case firewall needs to punch a hole for the
   # statd port...
   if [ -x /etc/init.d/SuSEfirewall2_setup ]; then
       /etc/init.d/SuSEfirewall2_setup try-restart > /dev/null 2>&1
   fi
fi
exit $st
