#!/bin/sh
#
# bb:	Starts the bb daemon
#


# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0

config() {
     echo "Making Big Brother links ..."
     cd /etc/rc.d/rc5.d
     ln -f -s ../init.d/bb S99bb
     ln -f -s ../init.d/bb K99bb
}

start() {
    echo -n $"Starting Big Brother: "
    /usr/krb5/bin/ksu bb -e /bb/bb/runbb.sh start 
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/bb
}

stop() {
    echo -n $"Stopping Big Brother: "
    /usr/krb5/bin/ksu bb -e /bb/bb/runbb.sh stop 
    RETVAL=$?
    echo
    if [ $RETVAL -eq 0 ]; then
        rm -f /var/lock/subsys/bb
    fi
}

# See how we were called.
case "$1" in
    config)
        config
        ;;
    start)
	start
	;;
    stop)
	stop
	;;
    *)
	echo $"Usage: $0 {config|start|stop}"
	;;
esac
exit $RETVAL