File: clamav-freshclam.config.in

package info (click to toggle)
clamav 0.101.4+dfsg-0+deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 29,564 kB
  • sloc: ansic: 158,978; sh: 8,178; cpp: 5,173; makefile: 2,088; yacc: 1,351; lex: 714; python: 120; perl: 17
file content (174 lines) | stat: -rw-r--r-- 4,577 bytes parent folder | download | duplicates (9)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/sh

set -e

# Source debconf library
. /usr/share/debconf/confmodule

# This conf script is capable of backing up
db_version 2.0
db_capb backup

#COMMON-FUNCTIONS#

FRESHCLAMCONF='/etc/clamav/freshclam.conf'

if [ -n "$http_proxy" ]; then 
  db_set clamav-freshclam/http_proxy "$http_proxy" || true
fi

# Read the configuration file
slurp_config "$FRESHCLAMCONF"

# Store conf file values as debconf answers - make sure user changes made 
# outside of debconf are preserved
[ -f /var/lib/clamav/interface ] && Interface=`cat /var/lib/clamav/interface`
if [ -n "$Interface" ]; then
  db_set clamav-freshclam/autoupdate_freshclam ifup.d || true
fi
if [ -n "$Interface" ]; then
  db_set clamav-freshclam/internet_interface "$Interface" || true
fi
if [ -n "$DatabaseMirror" ]; then
  # pick the first entry, there may be more than one of them
  DatabaseMirror="`echo $DatabaseMirror | awk '{print $1}'`"
  if [ -e /usr/share/doc/clamav-freshclam/mirror-list.gz ]; then
    if zgrep -q "$DatabaseMirror" /usr/share/doc/clamav-freshclam/mirror-list.gz;then
      db_set clamav-freshclam/local_mirror `zgrep "$DatabaseMirror" /usr/share/doc/clamav-freshclam/mirror-list.gz` || true
    else
      db_set clamav-freshclam/local_mirror "$DatabaseMirror" || true
    fi
  fi
fi
if [ -n "$HTTPProxyServer" ]; then
  db_set clamav-freshclam/http_proxy "http://$HTTPProxyServer:$HTTPProxyPort/" || true
fi
if [ -n "$HTTPProxyUsername" ]; then
  db_set clamav-freshclam/proxy_user "$HTTPProxyUsername:$HTTPProxyPassword" || true
fi
if [ -n "$Checks" ]; then
  db_set clamav-freshclam/update_interval "$Checks" || true
fi
if [ -n "$NotifyClamd" ]; then
  # clamav-freshclam/NotifyClamd is a boolean template, but the postinst writes
  # the path to the clamav-daemon configuration file to the freshclam.conf
  [ "$NotifyClamd" = "/etc/clamav/clamd.conf" ] && NotifyClamd="true"
  db_set clamav-freshclam/NotifyClamd "$NotifyClamd" || true
fi
set_debconf_value freshclam SafeBrowsing
set_debconf_value freshclam Bytecode
set_debconf_value freshclam PrivateMirror
set_debconf_value freshclam LogRotate


# States

StateInit()
{
  STATE="autoupdate_freshclam"
}

Stateautoupdate_freshclam()
{
  db_input medium clamav-freshclam/autoupdate_freshclam || true
  if db_go; then
    db_metaget clamav-freshclam/autoupdate_freshclam value || true
    if [ "$RET" = "ifup.d" ]; then
      STATE="internet_interface"
    else
      STATE="local_mirror"
    fi
  else
    STATE="End"
  fi
}

Statelocal_mirror()
{
  db_input medium clamav-freshclam/local_mirror || true
  if ! db_go; then
    STATE="autoupdate_freshclam"
  else
    db_metaget clamav-freshclam/local_mirror value || true
    if [ -z "$RET" ]; then
      db_set clamav-freshclam/local_mirror 'db.local.clamav.net' || true
    fi
    STATE="http_proxy"
  fi
}

Statehttp_proxy()
{
  db_input medium clamav-freshclam/http_proxy || true
  if ! db_go; then
    STATE="local_mirror"
  else
    db_metaget clamav-freshclam/http_proxy value || true
    if [ -z "$RET" ]; then
      STATE="update_interval"
    else
      STATE="proxy_user"
    fi
  fi
}

Stateupdate_interval()
{
  db_input low clamav-freshclam/update_interval || true
  if ! db_go; then
    STATE="http_proxy"
  else
    db_metaget clamav-freshclam/update_interval value || true
    if [ -z "$RET" ]; then
      db_set clamav-freshclam/update_interval 12 || true
    fi
    STATE="notify_daemon"
  fi
}

# This is the statemachine that controls execution. All the 'real' work is 
# performed by subfunctions above. 

STATE="Init"
while [ "$STATE" != "End" ]; do
  case "$STATE" in
    Init)
    StateInit
    ;;
    autoupdate_freshclam)
    Stateautoupdate_freshclam
    ;;
    local_mirror)
    Statelocal_mirror
    ;;
    http_proxy)
    Statehttp_proxy
    ;;
    proxy_user)
    StateGeneric medium clamav-freshclam/proxy_user update_interval http_proxy
    ;;
    internet_interface)
    StateGeneric high clamav-freshclam/internet_interface local_mirror autoupdate_freshclam
    ;;
    update_interval)
    Stateupdate_interval
    ;;
    notify_daemon)
    StateGeneric medium clamav-freshclam/NotifyClamd safebrowsing update_interval
    ;;
    safebrowsing)
    StateGeneric low clamav-freshclam/SafeBrowsing bytecode notify_daemon
    ;;
    bytecode)
    StateGeneric low clamav-freshclam/Bytecode private_mirror safebrowsing
    ;;
    private_mirror)
    StateGeneric low clamav-freshclam/PrivateMirror log_rotate bytecode
    ;;
    log_rotate)
    StateGeneric low clamav-freshclam/LogRotate End private_mirror
    ;;
  esac
done
db_stop || true
exit 0