~ubuntu-branches/ubuntu/trusty/clamav/trusty-proposed

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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
# 2004-01-25, Thomas Lamy <thomas.lamy@in-online.net>
# From Magnus Ekdahl's <magnus@debian.org> clamav-freshclam-handledaemon(8)

set -e

[ -e /var/lib/clamav/interface ] || exit 0

INIT=/etc/init.d/clamav-freshclam
CLAMAV_CONF_FILE=/etc/clamav/clamd.conf
FRESHCLAM_CONF_FILE=/etc/clamav/freshclam.conf

INTERNETIFACE=`cat /var/lib/clamav/interface`

if grep -q freshclam /proc/*/stat 2>/dev/null; then
  IS_RUNNING=true
else
  IS_RUNNING=false
fi

# $IFACE is set by ifup/down, $PPP_IFACE by pppd 
[ -n "$PPP_IFACE" ] && IFACE=$PPP_IFACE

# This is sloppy - woody's pppd exports variables, while sid's passes them as 
# arguments and exports them.

if [ "$1" = "$IFACE" ]; then # We're called by sid's pppd
  shift 6                    # and we already know the interface
fi                           # Dump the arguments passed.

if [ -z "$1" ]; then
  case $(dirname "$0") in
    */if-up.d|*/ip-up.d)
    # Short circuit and exit early if freshclam is already running
    [ "$IS_RUNNING" = 'true' ] && exit 0
    for interface in $INTERNETIFACE; do
      if [ "$interface" = "$IFACE" ]; then
	FMODE=start
	break
      else
	FMODE=skip
      fi
    done
    ;;
    */if-down.d|*/ip-down.d)
    # Short circuit and exit early if freshclam is not already running
    [ "$IS_RUNNING" = 'false' ] && exit 0
    for interface in $INTERNETIFACE; do
      if [ "$interface" = "$IFACE" ]; then
	FMODE=stop
	break
      else
	FMODE=skip
      fi
    done
    ;;
    *)
    FMODE=skip
    ;;
  esac
else
  FMODE="$1"
fi

case "$FMODE" in
  start|stop)
  IFACE="$IFACE" $INIT $FMODE
  ;;
  skip)
  ;;
  *)
  echo "Usage: $0 {start|stop|skip}" >&2
  exit 1
  ;;
esac

exit 0