ypbind/ypbind-post-waitbind

48 lines
1.0 KiB
Plaintext
Raw Normal View History

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