#!/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() {
    gprintf "Starting up drwebd: "
    daemon $DRWCMD
    RETVAL=$?
    [ $RETVAL -eq 0 ] && touch $DRWLCK
    echo
    return $RETVAL
}

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

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

restart() {
    stop
    start
    return $RETVAL
}

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

exit $RETVAL
													    			