cvsextras 47272f
#!/bin/bash
cvsextras 47272f
#
cvsextras 47272f
# Xchkconfig: - 75 25
cvsextras 47272f
# Xdescription: The clamd daemon listens for incoming connections on		\
cvsextras 47272f
#               Unix or TCP socket and scans files or directories on demand.
cvsextras 47272f
cvsextras 47272f
test "$CLAMD_SERVICE" || {
cvsextras 47272f
    echo $"*** $0 can not be called in this way"
cvsextras 47272f
    echo $"*** Please see /usr/share/doc/clamav-server-*/README how"
cvsextras 47272f
    echo $"*** the clamav-server can be configured"
cvsextras 47272f
    exit 6
cvsextras 47272f
}
cvsextras 47272f
cvsextras 47272f
# Source function library.
cvsextras 47272f
. /etc/init.d/functions
cvsextras 47272f
cvsextras 47272f
# Get config.
cvsextras 47272f
test -r /etc/sysconfig/network && . /etc/sysconfig/network
cvsextras 47272f
cvsextras 47272f
# Check that networking is up.
cvsextras 47272f
test "$NETWORKING" != "no" || exit 6
cvsextras 47272f
cvsextras 47272f
lockfile=/var/lock/subsys/clamd.${CLAMD_SERVICE}
cvsextras 47272f
sysconffile=/etc/sysconfig/clamd.${CLAMD_SERVICE}
cvsextras 47272f
procname=clamd.${CLAMD_SERVICE}
cvsextras 47272f
cvsextras 47272f
CLAMD_CONFIGFILE=/etc/clamd.d/${CLAMD_SERVICE}.conf
cvsextras 47272f
CLAMD_OPTIONS=
cvsextras 47272f
## backward-compatibility check...
cvsextras 47272f
for i in /var/run/clamd.${CLAMD_SERVICE}/clamd.sock \
cvsextras 47272f
         /var/run/clamav.${CLAMD_SERVICE}/clamd.sock; do
cvsextras 47272f
  CLAMD_SOCKET=$i
cvsextras 47272f
  test ! -e "$i" || break
cvsextras 47272f
done
cvsextras 47272f
test -f "$sysconffile" && . "$sysconffile"
cvsextras 47272f
cvsextras 47272f
cvsextras 47272f
RETVAL=0
cvsextras 47272f
prog="clamd.${CLAMD_SERVICE}"
cvsextras 47272f
cvsextras 47272f
start () {
cvsextras 47272f
	echo -n $"Starting $prog: "
cvsextras 47272f
	daemon $procname  ${CLAMD_CONFIGFILE:+-c $CLAMD_CONFIGFILE} ${CLAMD_OPTIONS}
cvsextras 47272f
	RETVAL=$?
cvsextras 47272f
	echo
cvsextras 47272f
	[ $RETVAL -eq 0 ] && touch $lockfile
cvsextras 47272f
	return $RETVAL
cvsextras 47272f
}
cvsextras 47272f
cvsextras 47272f
stop () {
cvsextras 47272f
	echo -n $"Stopping $prog: "
cvsextras 47272f
	killproc $procname
cvsextras 47272f
	RETVAL=$?
cvsextras 47272f
	echo
cvsextras 47272f
	[ $RETVAL -eq 0 ] && rm -f touch $lockfile
cvsextras 47272f
	return $RETVAL
cvsextras 47272f
}
cvsextras 47272f
cvsextras 47272f
reload() {
cvsextras 47272f
	rc=0
cvsextras 47272f
	echo -n $"Reloading $prog: "
cvsextras 47272f
	killproc $procname -SIGHUP  || rc=$?
cvsextras 47272f
	echo
cvsextras 47272f
	echo -n $"Loading new virus-database: "
cvsextras 47272f
	killproc $procname -SIGUSR2 || rc=$?
cvsextras 47272f
	echo
cvsextras 47272f
	return $rc
cvsextras 47272f
}
cvsextras 47272f
cvsextras 47272f
restart () {
cvsextras 47272f
	stop
cvsextras 47272f
	start
cvsextras 47272f
}
cvsextras 47272f
cvsextras 47272f
# See how we were called.
cvsextras 47272f
case "$1" in
cvsextras 47272f
  start|stop|restart|reload)
cvsextras 47272f
	$1 ;;
cvsextras 47272f
  status)
cvsextras 47272f
	status $procname ;;
cvsextras 47272f
  condrestart)
cvsextras 47272f
	test ! -f $lockfile || restart
cvsextras 47272f
	;;
cvsextras 47272f
  *)
cvsextras 47272f
	echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
cvsextras 47272f
	exit 2
cvsextras 47272f
esac