~ubuntu-branches/ubuntu/saucy/clamav/saucy-backports

« back to all changes in this revision

Viewing changes to debian/clamav-freshclam.postinst.in

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2014-07-15 01:08:10 UTC
  • mfrom: (0.35.47 sid)
  • Revision ID: package-import@ubuntu.com-20140715010810-ru66ek4fun2iseba
Tags: 0.98.4+dfsg-2~ubuntu13.10.1
No-change backport to saucy (LP: #1341962)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#loading debconf module
27
27
. /usr/share/debconf/confmodule
28
28
 
 
29
#COMMON-FUNCTIONS#
 
30
 
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
34
36
 
35
 
#COMMON-FUNCTIONS#
36
 
 
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
43
 
 
44
 
        test -e "$LOCAL_APP_PROFILE" || {
45
 
            tmp=`mktemp`
46
 
        cat <<EOM > "$tmp"
47
 
# Site-specific additions and overrides for usr.bin.freshclam.
48
 
# For more details, please see /etc/apparmor.d/local/README.
49
 
EOM
50
 
            mkdir `dirname $LOCAL_APP_PROFILE` 2>/dev/null || true
51
 
            mv -f "$tmp" "$LOCAL_APP_PROFILE"
52
 
            chmod 644 "$LOCAL_APP_PROFILE"
53
 
        }
54
 
 
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
58
 
        fi
59
 
    fi
60
 
fi
61
 
 
62
37
case "$1" in
63
38
  configure)
64
39
 
66
41
  dbowner=clamav
67
42
  udlogfile="$FRESHCLAMLOGFILE"
68
43
  maxatt=5
69
 
  
 
44
 
 
45
  # Read the configuration file
 
46
  slurp_config "$FRESHCLAMCONFFILE"
 
47
 
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}'`
75
53
  else
76
54
    mirrors="$rawmirrors"
77
55
  fi
78
 
  db_metaget clamav-freshclam/autoupdate_freshclam value || true
 
56
  db_get clamav-freshclam/autoupdate_freshclam || true
79
57
  runas="$RET"
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
83
61
      iface="$RET"
84
62
    else
87
65
    fi
88
66
  fi
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
93
 
        checks="$RET"
 
71
        checks="$RET"
94
72
      else
95
73
        if [ "$RET" -ge 24 ]; then
96
74
          echo "To check for updates more often than hourly, please run freshclam as a daemon."
101
79
      fi
102
80
    fi
103
81
  fi
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`"
118
96
    fi
119
97
  fi
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
123
 
  bytecode="$RET"
124
 
  db_metaget clamav-base/LogRotate value || true
 
100
  db_get clamav-freshclam/SafeBrowsing || true
 
101
  SafeBrowsing="$RET"
 
102
  db_get clamav-freshclam/Bytecode || true
 
103
  Bytecode="$RET"
 
104
  db_get clamav-freshclam/LogRotate || true
125
105
  LogRotate="$RET"
126
 
  db_metaget clamav-freshclam/PrivateMirror value || true
 
106
  db_get clamav-freshclam/PrivateMirror || true
127
107
  PrivateMirror="$RET"
128
108
 
129
 
  slurp_config "$FRESHCLAMCONFFILE"
130
 
 
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
135
113
    LogRotate="$RET"
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"
145
122
 
146
123
  if [ -n "$udlogfile" ]; then
147
124
    if echo "$udlogfile" | grep -q '^/dev/'; then
148
125
      make_logrotate=false
149
126
    else
150
 
      if [ -n "$LogRotate" ]; then
 
127
      if [ "$LogRotate" = "true" ]; then
151
128
        make_logrotate=true
152
129
      else
153
130
        make_logrotate=false
154
131
      fi
155
132
    fi
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
215
193
  else
216
194
    [ -f /var/lib/clamav/interface ] && rm -f /var/lib/clamav/interface
 
195
 
217
196
  fi
218
 
  
219
 
  dpkg --compare-versions "$2" lt 0.79 && DNSDatabaseInfo=current.cvd.clamav.net # Only for this upgrade
220
 
  
 
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
238
214
 
239
215
  # Generate config file
240
216
  cat >> $DEBCONFILE << EOF
261
237
TestDatabases $TestDatabases
262
238
ScriptedUpdates $ScriptedUpdates
263
239
CompressLocalDatabase $CompressLocalDatabase
264
 
Bytecode $bytecode
 
240
SafeBrowsing $SafeBrowsing
 
241
Bytecode $Bytecode
265
242
EOF
266
243
 
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
382
358
    update-rc.d -f clamav-freshclam remove > /dev/null 2>&1
383
359
  fi
384
360
  ;;
385
 
  abort-remove|abort-deconfigure|abort-upgrade)
 
361
  abort-upgrade|abort-remove|abort-deconfigure)
386
362
  ;;
387
363
  *)
388
364
  echo "postinst called with unknown argument \`$1'" >&2
390
366
  ;;
391
367
esac
392
368
 
 
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
 
375
 
 
376
        test -e "$LOCAL_APP_PROFILE" || {
 
377
            tmp=`mktemp`
 
378
        cat <<EOM > "$tmp"
 
379
# Site-specific additions and overrides for usr.bin.freshclam.
 
380
# For more details, please see /etc/apparmor.d/local/README.
 
381
EOM
 
382
            mkdir `dirname $LOCAL_APP_PROFILE` 2>/dev/null || true
 
383
            mv -f "$tmp" "$LOCAL_APP_PROFILE"
 
384
            chmod 644 "$LOCAL_APP_PROFILE"
 
385
        }
 
386
 
 
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
 
390
        fi
 
391
    fi
 
392
fi
 
393
 
 
394
# dh_installdeb will replace this with shell code automatically
 
395
# generated by other debhelper scripts.
 
396
 
393
397
#DEBHELPER#
394
398
 
395
399
exit 0