ypbind/ypbind-post-waitbind

56 lines
1.3 KiB
Bash
Executable File

#!/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=$NISTIMEOUT
firsttime=1
rpcbound=0
SECONDS=0
retval=0
while [ $SECONDS -lt $timeout ] || [ $firsttime -eq 1 ] ; do
firsttime=0
if /usr/sbin/rpcinfo -p | LC_ALL=C fgrep -q ypbind
then
rpcbound=1
/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
if [ $rpcbound -eq 0 ]; then
logger -t ypbind \
"NIS domain: `domainname`, ypbind not registered with rpcbind."
else
logger -t ypbind \
"NIS domain: `domainname`, NIS server: `ypwhich 2> /dev/null`"
fi
else
logger -t ypbind \
"NIS server for domain `domainname` is not responding."
logger -t ypbind \
"Killing ypbind with PID $MAINPID."
kill SIGTERM $MAINPID || :
fi
exit $retval