summaryrefslogtreecommitdiffstats
path: root/clamav/build/rc.clamav
blob: f79330228d8e74833d31f0ae7901819e44fc5f66 (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
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
# Start/stop/restart clamav.
# $Id$
# Author: Eric Hameleers <alien@slackware.com>
# ---------------------------------------------------------------------------

# Set to '1' if you want milter support:
MILTER=0

# Start clamav:
clamav_start() {
  # Remove zero-size db files - they are initial package placeholders:
  for DBFILE in /usr/share/clamav/main.cvd /usr/share/clamav/daily.cvd /usr/share/clamav/bytecode.cvd /usr/share/clamav/mirrors.dat ]; do
    if [ ! -s $DBFILE ]; then
      rm -f $DBFILE
    fi
  done
  if [ -x /usr/sbin/clamd ]; then
    echo -n "Starting clamd daemon:  /usr/sbin/clamd "
    /usr/sbin/clamd
    echo "."
    # Give clamd a chance to create the socket
    sleep 1
    echo -n "Starting freshclam daemon:  /usr/bin/freshclam -d -l /var/log/clamav/freshclam.log "
    /usr/bin/freshclam -d -l /var/log/clamav/freshclam.log
    echo "."
    if [ "$MILTER" == "1" ]; then
      echo -n "Starting clamav-milter daemon:  /usr/sbin/clamav-milter -dblo --max-children=2 local:/var/run/clamav/clmilter.sock "
      /usr/sbin/clamav-milter -dblo --max-children=2 local:/var/run/clamav/clmilter.sock
      echo "."
    fi
  fi
}

# Stop clamav:
clamav_stop() {
  kill $(cat /var/run/clamav/clamd.pid)
  #killall freshclam
  kill $(cat /var/run/clamav/freshclam.pid)
  [ "$MILTER" == "1" ] && killall clamav-milter
}

# Restart clamav:
clamav_restart() {
  clamav_stop
  sleep 1
  clamav_start
}

case "$1" in
'start')
  clamav_start
  ;;
'stop')
  clamav_stop
  ;;
'restart')
  clamav_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac