Blob Blame Raw
#!/bin/bash
#
# Xchkconfig: - 75 25
# Xdescription: The clamd daemon listens for incoming connections on		\
#               Unix or TCP socket and scans files or directories on demand.

test "$CLAMD_SERVICE" || {
    echo $"*** $0 can not be called in this way"
    echo $"*** Please see /usr/share/doc/clamav-server-*/README how"
    echo $"*** the clamav-server can be configured"
    exit 6
}

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

# Get config.
test -r /etc/sysconfig/network && . /etc/sysconfig/network

# Check that networking is up.
test "$NETWORKING" != "no" || exit 6

lockfile=/var/lock/subsys/clamd.${CLAMD_SERVICE}
sysconffile=/etc/sysconfig/clamd.${CLAMD_SERVICE}
procname=clamd.${CLAMD_SERVICE}

CLAMD_CONFIGFILE=/etc/clamd.d/${CLAMD_SERVICE}.conf
CLAMD_OPTIONS=
## backward-compatibility check...
for i in /var/run/clamd.${CLAMD_SERVICE}/clamd.sock \
         /var/run/clamav.${CLAMD_SERVICE}/clamd.sock; do
  CLAMD_SOCKET=$i
  test ! -e "$i" || break
done
test -f "$sysconffile" && . "$sysconffile"


RETVAL=0
prog="clamd.${CLAMD_SERVICE}"

start () {
	echo -n $"Starting $prog: "
	daemon $procname  ${CLAMD_CONFIGFILE:+-c $CLAMD_CONFIGFILE} ${CLAMD_OPTIONS}
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch $lockfile
	return $RETVAL
}

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

reload() {
	rc=0
	echo -n $"Reloading $prog: "
	killproc $procname -SIGHUP  || rc=$?
	echo
	echo -n $"Loading new virus-database: "
	killproc $procname -SIGUSR2 || rc=$?
	echo
	return $rc
}

restart () {
	stop
	start
}

# See how we were called.
case "$1" in
  start|stop|restart|reload)
	$1 ;;
  status)
	status $procname ;;
  condrestart)
	test ! -f $lockfile || restart
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
	exit 2
esac