5a592e
#!/bin/sh
5a592e
#
5a592e
# ypbind-domain
5a592e
#
5a592e
# description: This is part of former ypbind init script, which is used 
5a592e
#              to fix problems with the init scripts continuing even when 
5a592e
#              we are really not bound yet to a server, and then things
5a592e
#              that need NIS fail.
5a592e
#
5a592e
5a592e
# NISTIMEOUT should be a multiple of 15 since
5a592e
# ypwhich has a hardcoded 15sec timeout
5a592e
[ -z "$NISTIMEOUT" ] && NISTIMEOUT=45
5a592e
5a592e
logger -t ypbind $"Binding NIS service"
5a592e
5a592e
timeout=$NISTIMEOUT
5a592e
firsttime=1
5a592e
rpcbound=0
5a592e
SECONDS=0
5a592e
retval=0
5a592e
while [ $SECONDS -lt $timeout ] || [ $firsttime -eq 1 ] ; do
5a592e
firsttime=0
5a592e
if /usr/sbin/rpcinfo -p | LC_ALL=C fgrep -q ypbind
5a592e
then
5a592e
    rpcbound=1
5a592e
    /usr/bin/ypwhich > /dev/null 2>&1
5a592e
    retval=$?
5a592e
    if [ $retval -eq 0 ]; then
5a592e
	break;
5a592e
    fi
5a592e
fi
5a592e
sleep 2
5a592e
done
5a592e
5a592e
logger -t ypbind "Binding took $SECONDS seconds"
5a592e
5a592e
if [ $retval -eq 0 ]; then
5a592e
    if [ $rpcbound -eq 0 ]; then
5a592e
        logger -t ypbind \
5a592e
            "NIS domain: `domainname`, ypbind not registered with rpcbind."
5a592e
    else
5a592e
        logger -t ypbind \
5a592e
            "NIS domain: `domainname`, NIS server: `ypwhich 2> /dev/null`"
5a592e
    fi
5a592e
else
5a592e
    logger -t ypbind \
5a592e
        "NIS server for domain `domainname` is not responding."
5a592e
    logger -t ypbind \
5a592e
        "Killing ypbind with PID $MAINPID."
5a592e
    kill -s 15 $MAINPID || :
5a592e
    logger -t ypbind \
5a592e
        "Try increase NISTIMEOUT in /etc/sysconfig/ypbind"
5a592e
fi
5a592e
5a592e
exit $retval
5a592e