#!/bin/sh
#
# eb_client_file - Entropy broker linux kernel client
# SVN: $Revision$
#
# chkconfig:   2345 28 83
# description: This daemon installs brokered entropy into the linux kernel
#
# processname: eb_client_file
# pidfile: /usr/local/entropybroker/var/run/eb_client_file.pid

### BEGIN INIT INFO
# Provides: eb_client_file
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop linux kernel entropy client
# Description: eb_client_file is a daemon for installing brokered entropy into the kernel.
### END INIT INFO

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

exec="/usr/local/entropybroker/bin/eb_client_file"
prog=$(basename $exec)

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/$prog

start() {
    echo -n $"Starting $prog: "

    $exec $OPTIONS
    retval=$?
    [ $retval -ne 0 ] && failure
    [ $retval -eq 0 ] && success && touch $lockfile
    echo
    return $retval
}

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    stop
    start
}

case "$1" in
    start|stop|restart)
        $1
        ;;
    force-reload)
        restart
        ;;
    status)
        status $prog
        ;;
    try-restart|condrestart)
        if status $prog >/dev/null ; then
            restart
        fi
        ;;
    reload)
        killproc $prog -HUP
        exit 3
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
        exit 2
esac

