#!/bin/sh
#
# yellowpages -- start or stop yellow pages
#

. /etc/rc.d/sysconfig

case "$1" in
start)

    if [ "$DOMAINNAME" ]; then
	need network portmapper

	echo -n "starting Yellow Pages:"
	echo -n " $DOMAINNAME"
	domainname $DOMAINNAME
    
	if [ "$YPMASTER" ]; then
	    # default:  don't run ypbind on a yellow pages master
	    SERVICES="ypserv rpc.yppasswdd"
	else
	    SERVICES=ypbind
	fi

	for daemon in $SERVICES; do
	    if [ -x /usr/sbin/$daemon ]; then
		echo -n " $daemon"
		/usr/sbin/$daemon
	    fi
	done
	echo
    fi
    ;;

info)
    echo "Yellow Pages"
    ;;
stop)
    PREFIX="stopping Yellow pages:"
    for i in ypbind yppasswdd ypserv; do
	if [ -r /var/run/${i}.pid ]; then
	    echo -n "$PREFIX $i"
	    PID=`cat /var/run/${i}.pid`
	    ${PID:+kill $PID}
	    unset PREFIX
	fi
    done
    test "$PREFIX" || echo "."
    ;;
*)
    echo "usage: $0 {start|stop}"
    ;;
esac
