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