~ubuntu-branches/ubuntu/breezy/clamav/breezy-backports

« back to all changes in this revision

Viewing changes to debian/clamav-freshclam.config

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Gran
  • Date: 2005-09-19 09:05:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050919090559-hikpqduq8yx5qxo2
Tags: 0.87-1
* New upstream version
  - Fixes CAN-2005-2920 and CAN-2005-2919 (closes: #328660)
* New logcheck line for clamav-daemon (closes: #323132)
* relibtoolize and apply kfreebsd patch (closes: #327707)
* Make sure init.d script starts freshclam up again after upgrade when run
  from if-up.d (closes: #328912)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh -e
2
 
 
3
 
# Source debconf library
4
 
. /usr/share/debconf/confmodule
5
 
 
6
 
# This conf script is capable of backing up
7
 
db_version 2.0
8
 
db_capb backup
9
 
 
10
 
# Get user config
11
 
 
12
 
FRESHCLAMCONF='/etc/clamav/freshclam.conf'
13
 
 
14
 
if [ -f "$FRESHCLAMCONF" ]; then
15
 
  for variable in `egrep -v '^[[:space:]]*(#|$)' "$FRESHCLAMCONF" | awk '{print $1}'`; do
16
 
    value=`grep ^$variable $FRESHCLAMCONF | head -n1 | sed -e s/$variable\ *//`
17
 
    if ! [ "$value" = "$variable" -o "$value" = "" ]; then
18
 
      export "$variable"="$value"
19
 
    else
20
 
      export "$variable"="true"
21
 
    fi
22
 
  done
23
 
fi
24
 
 
25
 
# Only show note if mirrors.txt is changed
26
 
 
27
 
if [ -e /var/lib/clamav/mirrors.txt ]; then
28
 
  OLD_SUM=26d0b72130f60bce6e687d8a6eef93b7
29
 
  NEW_SUM=`md5sum /var/lib/clamav/mirrors.txt | awk '{print $1}'`
30
 
  if ! [ "$OLD_SUM" = "$NEW_SUM" ]; then
31
 
    db_input high clamav-freshclam/mirrors.txt-note || true
32
 
  fi
33
 
fi
34
 
 
35
 
# Set debconf values from config file 
36
 
 
37
 
if [ -f /var/lib/clamav/interface ]; then
38
 
  Interface=`cat /var/lib/clamav/interface`
39
 
fi
40
 
if [ -n "$Interface" ]; then
41
 
  db_set clamav-freshclam/autoupdate_freshclam ifup.d || true
42
 
fi
43
 
if [ -n "$Interface" ]; then
44
 
  db_set clamav-freshclam/internet_interface "$Interface" || true
45
 
fi
46
 
if [ -n "$DatabaseMirror" ]; then
47
 
  db_set clamav-freshclam/mirrors "$DatabaseMirror" || true
48
 
fi
49
 
if [ -n "$HTTPProxyServer" ]; then
50
 
  db_set clamav-freshclam/http_proxy "$HTTPProxyServer:$HTTPProxyPort" || true
51
 
fi
52
 
if [ -n "$HTTPProxyUsername" ]; then
53
 
  db_set clamav-freshclam/proxy_user "$HTTPProxyUsername:$HTTPProxyPassword" || true
54
 
fi
55
 
if [ -n "$Checks" ]; then
56
 
  db_set clamav-freshclam/update_interval "$Checks" || true
57
 
fi
58
 
if [ -n "$NotifyClamd" ]; then
59
 
  db_set clamav-freshclam/NotifyClamd "$NotifyClamd" || true
60
 
fi
61
 
 
62
 
# States
63
 
 
64
 
StateInit()
65
 
{
66
 
  STATE="autoupdate_freshclam"
67
 
}
68
 
 
69
 
Stateautoupdate_freshclam()
70
 
{
71
 
  db_input medium clamav-freshclam/autoupdate_freshclam || true
72
 
  if db_go; then
73
 
    db_metaget clamav-freshclam/autoupdate_freshclam value || true
74
 
    if [ "$RET" = "ifup.d" ]; then
75
 
      STATE="internet_interface"
76
 
    else
77
 
      STATE="mirrors"
78
 
    fi
79
 
  else
80
 
    STATE="End"
81
 
  fi
82
 
}
83
 
 
84
 
 
85
 
Stateinternet_interface()
86
 
{
87
 
  db_input high clamav-freshclam/internet_interface || true
88
 
  if db_go; then
89
 
    STATE="mirrors"
90
 
  else
91
 
    STATE="autoupdate_freshclam"
92
 
  fi
93
 
}
94
 
 
95
 
Statemirrors()
96
 
{
97
 
  db_input medium clamav-freshclam/mirrors || true
98
 
  if ! db_go; then
99
 
    STATE="autoupdate_freshclam"
100
 
  else
101
 
    db_metaget clamav-freshclam/mirrors value || true
102
 
    if [ -z "$RET" ]; then
103
 
      db_set clamav-freshclam/mirrors 'database.clamav.net' || true
104
 
    else
105
 
      STATE="http_proxy"
106
 
    fi
107
 
  fi
108
 
}
109
 
 
110
 
Statehttp_proxy()
111
 
{
112
 
  db_input medium clamav-freshclam/http_proxy || true
113
 
  if ! db_go; then
114
 
    STATE="mirrors"
115
 
  else
116
 
    db_metaget clamav-freshclam/http_proxy value || true
117
 
    if [ -z "$RET" ]; then
118
 
      STATE="update_interval"
119
 
    else
120
 
      STATE="proxy_user"
121
 
    fi
122
 
  fi
123
 
}
124
 
 
125
 
Stateproxy_user()
126
 
{
127
 
  db_input medium clamav-freshclam/proxy_user || true
128
 
  if ! db_go; then
129
 
    STATE="http_proxy"
130
 
  else
131
 
    STATE="update_interval"
132
 
  fi
133
 
}
134
 
 
135
 
Stateupdate_interval()
136
 
{
137
 
  db_input low clamav-freshclam/update_interval || true
138
 
  if ! db_go; then
139
 
    STATE="http_proxy"
140
 
  else
141
 
    db_metaget clamav-freshclam/update_interval value || true
142
 
    if [ -z "$RET" ]; then
143
 
      db_set clamav-freshclam/update_interval 12 || true
144
 
    fi
145
 
    STATE="notify_daemon"
146
 
  fi
147
 
}
148
 
 
149
 
Statenotify_daemon()
150
 
{
151
 
  db_input medium clamav-freshclam/NotifyClamd || true
152
 
  if ! db_go; then
153
 
    STATE="update_interval"
154
 
  else
155
 
    STATE="End"
156
 
  fi
157
 
}
158
 
 
159
 
# This is the statemachine that controls execution. All the 'real' work is 
160
 
# performed by subfunctions above. 
161
 
 
162
 
STATE="Init"
163
 
while [ "$STATE" != "End" ]; do
164
 
  case "$STATE" in
165
 
    Init)
166
 
    StateInit
167
 
    ;;
168
 
    autoupdate_freshclam)
169
 
    Stateautoupdate_freshclam
170
 
    ;;
171
 
    mirrors)
172
 
    Statemirrors
173
 
    ;;
174
 
    http_proxy)
175
 
    Statehttp_proxy
176
 
    ;;
177
 
    proxy_user)
178
 
    Stateproxy_user
179
 
    ;;
180
 
    internet_interface)
181
 
    Stateinternet_interface
182
 
    ;;
183
 
    update_interval)
184
 
    Stateupdate_interval
185
 
    ;;
186
 
    notify_daemon)
187
 
    Statenotify_daemon
188
 
    ;;
189
 
  esac
190
 
done
191
 
db_stop || true
192
 
exit 0