26
26
#loading debconf module
27
27
. /usr/share/debconf/confmodule
29
31
FRESHCLAMCONFFILE=/etc/clamav/freshclam.conf
30
32
FRESHCLAMLOGFILE=/var/log/clamav/freshclam.log
31
33
DEBCONFILE=/var/lib/clamav/freshclam.conf
32
34
LOGROTFILE=/etc/logrotate.d/clamav-freshclam
33
35
DEBROTFILE=/var/lib/clamav/clamav-freshclam
37
# AppArmor integration
38
if [ "$1" = "configure" ]; then
39
APP_PROFILE=/etc/apparmor.d/usr.bin.freshclam
40
if [ -f "$APP_PROFILE" ]; then
41
# Add the local/ include
42
LOCAL_APP_PROFILE=/etc/apparmor.d/local/usr.bin.freshclam
44
test -e "$LOCAL_APP_PROFILE" || {
47
# Site-specific additions and overrides for usr.bin.freshclam.
48
# For more details, please see /etc/apparmor.d/local/README.
50
mkdir `dirname $LOCAL_APP_PROFILE` 2>/dev/null || true
51
mv -f "$tmp" "$LOCAL_APP_PROFILE"
52
chmod 644 "$LOCAL_APP_PROFILE"
55
# Reload the profile, including any abstraction updates
56
if aa-status --enabled 2>/dev/null; then
57
apparmor_parser -r -T -W "$APP_PROFILE" || true
67
42
udlogfile="$FRESHCLAMLOGFILE"
45
# Read the configuration file
46
slurp_config "$FRESHCLAMCONFFILE"
70
48
# Get the debconf answers
71
db_metaget clamav-freshclam/local_mirror value || true
49
db_get clamav-freshclam/local_mirror || true
72
50
[ "$RET" = "" ] || rawmirrors="$RET"
73
51
if echo "$rawmirrors" | egrep -q '(\(|\))'; then
74
52
mirrors=`echo "$rawmirrors" | awk '{print $1}'`
76
54
mirrors="$rawmirrors"
78
db_metaget clamav-freshclam/autoupdate_freshclam value || true
56
db_get clamav-freshclam/autoupdate_freshclam || true
80
58
if [ "$runas" = "ifup.d" ]; then
81
db_metaget clamav-freshclam/internet_interface value || true
59
db_get clamav-freshclam/internet_interface || true
82
60
if [ "$RET" != "" ]; then
89
67
if [ "$runas" = "ifup.d" ] || [ "$runas" = "daemon" ] || [ "$runas" = "cron" ]; then
90
db_metaget clamav-freshclam/update_interval value || true
68
db_get clamav-freshclam/update_interval || true
91
69
if [ "$RET" != "" ]; then
92
70
if [ "$runas" != "cron" ]; then
95
73
if [ "$RET" -ge 24 ]; then
96
74
echo "To check for updates more often than hourly, please run freshclam as a daemon."
104
db_metaget clamav-freshclam/http_proxy value || true
82
db_get clamav-freshclam/http_proxy || true
105
83
if [ "$RET" != "" ]; then
106
84
url="`echo "$RET" | sed -e 's,^http://,,g' | sed -e 's,/$,,g'`"
107
85
phost="`echo "$url" | cut -d':' -f 1`"
117
95
ppass="`echo "$RET" | cut -d':' -f 2`"
120
db_metaget clamav-freshclam/NotifyClamd value || true
98
db_get clamav-freshclam/NotifyClamd || true
121
99
[ "$RET" = "true" ] && notify="/etc/clamav/clamd.conf"
122
db_metaget clamav-base/Bytecode value || true
124
db_metaget clamav-base/LogRotate value || true
100
db_get clamav-freshclam/SafeBrowsing || true
102
db_get clamav-freshclam/Bytecode || true
104
db_get clamav-freshclam/LogRotate || true
126
db_metaget clamav-freshclam/PrivateMirror value || true
106
db_get clamav-freshclam/PrivateMirror || true
127
107
PrivateMirror="$RET"
129
slurp_config "$FRESHCLAMCONFFILE"
131
109
# Test for the broken versions, see #741675.
132
110
if [ "$2" = "0.98.1+dfsg-3" ] || [ "$2" = "0.98.1+dfsg-1+deb7u2" ] || [ "$2" = "0.98.1+dfsg-1+deb6u2" ]; then
133
111
# Use the defaults instead of the bogus values created by that versions.
134
db_metaget clamav-base/LogRotate default || true
112
db_metaget clamav-freshclam/LogRotate default || true
136
114
db_metaget clamav-freshclam/PrivateMirror default || true
137
115
PrivateMirror="$RET"
141
119
[ -n "$DatabaseOwner" ] && [ "$DatabaseOwner" != "$dbowner" ] && dbowner="$DatabaseOwner"
142
120
[ -n "$UpdateLogFile" ] && [ "$UpdateLogFile" != "$udlogfile" ] && udlogfile="$UpdateLogFile"
143
121
[ -n "$MaxAttempts" ] && [ "$MaxAttempts" != "$maxatt" ] && maxatt="$MaxAttempts"
144
[ -n "$Bytecode" ] && [ "$Bytecode" != "$bytecode" ] && bytecode="$Bytecode"
146
123
if [ -n "$udlogfile" ]; then
147
124
if echo "$udlogfile" | grep -q '^/dev/'; then
148
125
make_logrotate=false
150
if [ -n "$LogRotate" ]; then
127
if [ "$LogRotate" = "true" ]; then
151
128
make_logrotate=true
153
130
make_logrotate=false
156
[ -n "$User" ] || User=clamav
133
[ -z "$User" ] && User=clamav
157
134
if [ "$make_logrotate" = 'true' ]; then
135
# update the logrotate file
158
136
echo "$udlogfile {" > $DEBROTFILE
159
137
echo " rotate 12" >> $DEBROTFILE
160
138
echo " weekly" >> $DEBROTFILE
214
192
[ -n "$iface" ] && echo "$iface" > /var/lib/clamav/interface
216
194
[ -f /var/lib/clamav/interface ] && rm -f /var/lib/clamav/interface
219
dpkg --compare-versions "$2" lt 0.79 && DNSDatabaseInfo=current.cvd.clamav.net # Only for this upgrade
197
# Set default values for options not configured via debconf
198
[ -z "$DatabaseDirectory" ] && DatabaseDirectory='/var/lib/clamav'
199
[ -z "$LogFileMaxSize" ] && LogFileMaxSize=0
200
[ -z "$LogTime" ] && LogTime=true
221
201
[ -z "$LogVerbose" ] && LogVerbose=false
222
202
[ -z "$LogSyslog" ] && LogSyslog=false
223
203
[ -z "$LogFacility" ] && LogFacility=LOG_LOCAL6
224
[ -z "$LogFileMaxSize" ] && LogFileMaxSize=0
204
[ -z "$PidFile" ] && PidFile='/var/run/clamav/freshclam.pid'
205
[ -z "$AllowSupplementaryGroups" ] && AllowSupplementaryGroups=false
206
[ -z "$DNSDatabaseInfo" ] && DNSDatabaseInfo='current.cvd.clamav.net'
207
[ -z "$ScriptedUpdates" ] && ScriptedUpdates=yes
208
[ -z "$CompressLocalDatabase" ] && CompressLocalDatabase=no
225
209
[ -z "$Foreground" ] && Foreground=false
226
210
[ -z "$Debug" ] && Debug=false
227
[ -z "$DatabaseDirectory" ] && DatabaseDirectory='/var/lib/clamav'
228
[ -z "$DNSDatabaseInfo" ] && DNSDatabaseInfo='current.cvd.clamav.net'
229
[ -z "$AllowSupplementaryGroups" ] && AllowSupplementaryGroups=false
230
[ -z "$PidFile" ] && PidFile='/var/run/clamav/freshclam.pid'
231
211
[ -z "$ConnectTimeout" ] && ConnectTimeout=30
232
212
[ -z "$ReceiveTimeout" ] && ReceiveTimeout=30
233
213
[ -z "$TestDatabases" ] && TestDatabases=yes
234
[ -z "$ScriptedUpdates" ] && ScriptedUpdates=yes
235
[ -z "$LogTime" ] && LogTime=true
236
[ -z "$LogRotate" ] && LogRotate=true
237
[ -z "$CompressLocalDatabase" ] && CompressLocalDatabase=no
239
215
# Generate config file
240
216
cat >> $DEBCONFILE << EOF
261
237
TestDatabases $TestDatabases
262
238
ScriptedUpdates $ScriptedUpdates
263
239
CompressLocalDatabase $CompressLocalDatabase
240
SafeBrowsing $SafeBrowsing
267
244
if [ -n "$notify" ] ;then
306
283
[ -n "$SubmitDetectionStats" ] && echo "SubmitDetectionStats $SubmitDetectionStats" >> $DEBCONFILE
307
284
[ -n "$DetectionStatsCountry" ] && echo "DetectionStatsCountry $DetectionStatsCountry" >> $DEBCONFILE
308
285
[ -n "$DetectionStatsHostID" ] && echo "DetectionStatsHostID $DetectionStatsHostID" >> $DEBCONFILE
309
[ -n "$SafeBrowsing" ] && echo "SafeBrowsing $SafeBrowsing" >> $DEBCONFILE
310
286
[ -n "$PrivateMirror" ] && echo "PrivateMirror $PrivateMirror" >> $DEBCONFILE
311
287
if [ -n "$DatabaseCustomURL" ]; then
312
288
for i in $DatabaseCustomURL; do
369
# AppArmor integration
370
if [ "$1" = "configure" ]; then
371
APP_PROFILE=/etc/apparmor.d/usr.bin.freshclam
372
if [ -f "$APP_PROFILE" ]; then
373
# Add the local/ include
374
LOCAL_APP_PROFILE=/etc/apparmor.d/local/usr.bin.freshclam
376
test -e "$LOCAL_APP_PROFILE" || {
379
# Site-specific additions and overrides for usr.bin.freshclam.
380
# For more details, please see /etc/apparmor.d/local/README.
382
mkdir `dirname $LOCAL_APP_PROFILE` 2>/dev/null || true
383
mv -f "$tmp" "$LOCAL_APP_PROFILE"
384
chmod 644 "$LOCAL_APP_PROFILE"
387
# Reload the profile, including any abstraction updates
388
if aa-status --enabled 2>/dev/null; then
389
apparmor_parser -r -T -W "$APP_PROFILE" || true
394
# dh_installdeb will replace this with shell code automatically
395
# generated by other debhelper scripts.