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