5d0eef
#!/bin/sh
5d0eef
#
5d0eef
# ypbind-domain
5d0eef
#
5d0eef
# description: This is part of former ypbind init script, which is used 
5d0eef
#              to setup proper domainname before starting ypbind daemon 
5d0eef
#              itself. If $NISDOMAIN is not defined, it reads config file. 
5d0eef
#
5d0eef
5d0eef
TIMEOUT=5
5d0eef
DOMAINNAME=`domainname`
5d0eef
if [ "$DOMAINNAME" = "(none)" -o "$DOMAINNAME" = "" ]; then
5d0eef
    echo -n $"Setting NIS domain: "
5d0eef
    seconds=0
5d0eef
    while [ $seconds -lt $TIMEOUT ]; do
5d0eef
    if [ -n "$NISDOMAIN" ]; then
5d0eef
        domainname $NISDOMAIN
5d0eef
        echo $"'$NISDOMAIN' (environment variable)"
5d0eef
        break
5d0eef
    else # See if the domain is set in config file
5d0eef
        NISDOMAIN=`awk '{ if ($1 == "domain") {print $2; exit} }' /etc/yp.conf`
5d0eef
        if [ -n "$NISDOMAIN" ]; then
5d0eef
            domainname $NISDOMAIN
5d0eef
            echo $"'$NISDOMAIN' (/etc/yp.conf)"
5d0eef
            break
5d0eef
        else
5d0eef
            seconds=$(($seconds+1))
5d0eef
            sleep 1
5d0eef
        fi
5d0eef
    fi
5d0eef
    done
5d0eef
    # Give up if NISDOMAIN is still not set
5d0eef
    [ -z "$NISDOMAIN" ] && logger -t ypbind $"domain not found" && exit 1
5d0eef
fi
5d0eef
5d0eef
#/etc/rpc check
5d0eef
grep ypbind /etc/rpc > /dev/null 2>&1
5d0eef
if [ $? -ne 0 ]; then
5d0eef
    logger -t ypbind $"Error: Missing ypbind entry in /etc/rpc."
5d0eef
    exit 1
5d0eef
fi
5d0eef
5d0eef
echo 
5d0eef