summaryrefslogtreecommitdiff
path: root/recipes/clamav/files/clamav-daemon.init
blob: b506ccadb39a96c866cc4fc4d5fea3bcc3479c72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/clamd
NAME="clamd"
DESC="ClamAV daemon"
CLAMAV_CONF=/etc/clamd.conf
PID=/var/run/clamav/clamd.pid

set -e

test -x "$DAEMON" || exit 0
if [ ! -r "$CLAMAV_CONF" ]; then
  echo "ClamAV configuration file $CLAMAV_CONF not found. Exiting"
  exit 0
fi
if [ `grep -q "^Example" $CLAMAV_CONF` ]; then
    echo "$DESC is not configured."
    exit 0
fi

case "$1" in
  start)
    echo -n "Starting $DESC: "
    start-stop-daemon --oknodo -S -x $DAEMON
    echo "$NAME."
    ;;

  stop)
    echo -n "Stopping $DESC: "
    start-stop-daemon -K -p $PID
    for i in `seq 1 5`; do
	if start-stop-daemon -p $PID -t -K >/dev/null 2>&1; then
	    break;
	fi
	sleep 1
    done
    ;;

    restart|force-reload)
    $0 stop
    $0 start
    ;;

    *)
    echo "Usage: $0 {start|stop|restart|force-reload}" >&2
    exit 1
    ;;
esac

exit 0