#!/bin/sh
#
# chkconfig: 2345 70 30
# description: drwebd is a Dr.Web(R) Antivirus deamon
# processname: drwebd
# config: /etc/drweb/drweb32.ini
# pidfile: /var/drweb/run/drwebd.pid

DRWEBD="drwebd"
DRWCMD="/opt/drweb/$DRWEBD"
DRWLCK="/var/lock/subsys/$DRWEBD"

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

start() {
    echo -n $"Starting up drwebd: "
    daemon $DRWCMD
    RETVAL=$?
    [ $RETVAL -eq 0 ] && touch $DRWLCK
    echo
}

stop() {
    echo -n $"Shutting down drwebd: "
    killproc $DRWEBD
    RETVAL=$?
    [ $RETVAL -eq 0 ] && rm -f "$DRWLCK"
    echo
}

reload() {
    echo -n $"Reloading drwebd: "
    killproc $DRWEBD -HUP
    RETVAL=$?
    [ $RETVAL -eq 0 ] || rm -f "$DRWLCK"
    echo
}

restart() {
    stop
    start
}

dostatus() {
    status drwebd
    RETVAL=$?
}
	
# See how we were called.
case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    status)
	dostatus
	;;
    reload)
        reload
        ;;
    restart)
	restart
	;;
    condrestart)
        [ -e $DRWLCK ] && restart
	;;
    condreload)
        [ -e $DRWLCK ] && reload
	;;
    condstop)
        [ -e $DRWLCK ] && stop
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart|reload|condrestart|condreload|condstop}"
	exit 1
esac

exit $RETVAL
													    			