blob: 83eccada60d8b30521fc78d0afb277be93d4e6e9 (
plain)
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
##
## Created by Wolfram Schlich <wschlich@gentoo.org>
##
## TODO
## - install: shutdown running programs?
## - install: show EULA?!
## - config: setup avmailgate.acl?
## - install/config: copy keyfile?
## - config: setup mta config? -> show INSTALL.$mta file, at least
## - install/config: avguard? -> check if avspooldir is excluded in guard config
## - install/config: gui?
##
inherit eutils pax-utils
DESCRIPTION="AVIRA AntiVir MailGate SMTP mail virus scanner"
MY_P="${PN}-prof-${PV/_p/-}"
SRC_URI="http://wolfram.schlich.org/linux/gentoo/distfiles/${MY_P}.tar.gz"
HOMEPAGE="http://www.avira.com/"
LICENSE="AVIRA-AntiVir"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="postfix spamfilter" # TODO: gui exim qmail sendmail smc
DEPEND=""
RDEPEND=">=app-antivirus/antivir-savapi-3
postfix? ( mail-mta/postfix )"
S="${WORKDIR}/${MY_P}"
# prevent installation functions from stripping binaries
# otherwise the antivir selfcheck fails. also don't try
# to fetch the distribution tarball from a mirror.
RESTRICT="strip mirror"
#
# Settings overridable by user supplied environment variables
#
AVHOMEDIR="${AVHOMEDIR:-/usr/lib/AntiVir}"
AVCONFDIR="${AVCONFDIR:-/etc}"
AVSPOOLDIR="${AVSPOOLDIR:-/var/spool/avmailgate}"
AVTMPDIR="${AVTMPDIR:-/var/tmp}"
AVPIDDIR="${AVPIDDIR:-/var/tmp}"
AVSAVAPISOCKET="${AVSAVAPISOCKET:-/var/run/avmailgate/scanner}"
AVUSER="${AVUSER:-avgate}"
AVUID="${AVUID:-220}"
AVSH="${AVSH:--1}"
AVGROUP="${AVGROUP:-antivir}"
AVGID="${AVGID:-220}"
AVHOSTNAME="${AVHOSTNAME:-$(hostname -f)}"
#
# Standard ebuild functions
#
pkg_setup() {
#
# Add USER + GROUP
#
enewgroup "${AVGROUP}" "${AVGID}"
enewuser "${AVUSER}" "${AVUID}" "${AVSH}" -1 "${AVGROUP}" -c AntiVir
}
src_unpack() {
unpack ${A}
cd "${S}"
#
# MTA specific config
#
if use postfix; then
pushd ./etc >/dev/null \
&& epatch "${FILESDIR}/${PV}/avmailgate.conf.diff.postfix.bz2" \
&& popd >/dev/null
fi
#
# scanner config
#
pushd ./etc >/dev/null \
&& epatch "${FILESDIR}/${PV}/avmailgate-scanner.conf.diff.bz2" \
&& popd >/dev/null
}
src_install() {
#
# Base directories
#
if use spamfilter; then
diropts -oroot -g"${AVGROUP}" -m0750
dodir /var/tmp/AntiVir
diropts -o"${AVUSER}" -g"${AVGROUP}" -m0750
dodir /var/tmp/AntiVir/asmailgate
diropts ""
fi
#
# Executables, libraries and misc components
#
exeinto "${AVHOMEDIR}"
exeopts -oroot -g"${AVGROUP}" -m2750
doexe bin/linux_glibc22/avmailgate.bin
exeopts -oroot -g"${AVGROUP}" -m0750
newexe script/avira_start.sh.template avmailgate
doexe script/avmailgate_start.sh
doexe script/avmailgate_stop.sh
doexe script/avmailgate_restart.sh
doexe script/avmailgate_post.sh
diropts ""
dodir "${DESTTREE}/sbin"
dosym "${AVHOMEDIR}/avmailgate.bin" "${DESTTREE}/sbin/avmailgate"
if use spamfilter; then
exeopts -o"${AVUSER}" -g"${AVGROUP}" -m2750
exeinto "${AVHOMEDIR}"
doexe contrib/asmailgate/bin/linux_glibc22/avmg_ext_filter.bin
insopts -o"${AVUSER}" -g"${AVGROUP}" -m0644
insinto "${AVHOMEDIR}"
doins contrib/asmailgate/bin/linux_glibc22/libasmailgate.so
doins contrib/asmailgate/data/asmailgate.dat
fi
#
# Init script
#
exeopts -oroot -groot -m0755
exeinto /etc/init.d
newexe "${FILESDIR}/${PV}/antivir-mailgate.initd" antivir-mailgate
#
# Config
#
insopts -oroot -g"${AVGROUP}" -m0640
insinto "${AVCONFDIR}"
doins \
etc/avmailgate.acl \
etc/avmailgate.conf \
etc/avmailgate.ignore \
etc/avmailgate.scan \
etc/avmailgate.warn
# use gui && doins etc/avmailgate.conf-gui
dosed "s:%AVHOMEDIR%:${AVHOMEDIR}:g" "${AVCONFDIR}/avmailgate.conf"
dosed "s:%AVCONFDIR%:${AVCONFDIR}:g" "${AVCONFDIR}/avmailgate.conf"
dosed "s:%AVSPOOLDIR%:${AVSPOOLDIR}:g" "${AVCONFDIR}/avmailgate.conf"
dosed "s:%AVTMPDIR%:${AVTMPDIR}:g" "${AVCONFDIR}/avmailgate.conf"
dosed "s:%AVPIDDIR%:${AVPIDDIR}:g" "${AVCONFDIR}/avmailgate.conf"
dosed "s:%AVSAVAPISOCKET%:${AVSAVAPISOCKET}:g" "${AVCONFDIR}/avmailgate.conf"
dosed "s:%AVUSER%:${AVUSER}:g" "${AVCONFDIR}/avmailgate.conf"
dosed "s:%AVGROUP%:${AVGROUP}:g" "${AVCONFDIR}/avmailgate.conf"
dosed "s:%AVHOSTNAME%:${AVHOSTNAME}:g" "${AVCONFDIR}/avmailgate.conf"
doins etc/avmailgate-scanner.conf
dosed "s:%AVTMPDIR%:${AVTMPDIR}:g" "${AVCONFDIR}/avmailgate-scanner.conf"
dosed "s:%AVSAVAPISOCKET%:${AVSAVAPISOCKET}:g" "${AVCONFDIR}/avmailgate-scanner.conf"
dosed "s:%AVUSER%:${AVUSER}:g" "${AVCONFDIR}/avmailgate-scanner.conf"
dosed "s:%AVGROUP%:${AVGROUP}:g" "${AVCONFDIR}/avmailgate-scanner.conf"
if use spamfilter; then
dosed "s:^EnableSpamCheck NO:EnableSpamCheck YES:g" "${AVCONFDIR}/avmailgate.conf"
touch "${T}/asmailgate.except"
doins "${T}/asmailgate.except"
fi
#
# Spool directory
#
diropts -o"${AVUSER}" -g"${AVGROUP}" -m0700
dodir "${AVSPOOLDIR}"
keepdir "${AVSPOOLDIR}"
for dir in incoming outgoing rejected; do
dodir "${AVSPOOLDIR}/${dir}"
keepdir "${AVSPOOLDIR}/${dir}"
done
## TODO:GUI
## TODO:SMC
#
# Documents
#
dodoc \
LICENSE \
LICENSE.DE \
README \
doc/CHANGELOG \
doc/INSTALL \
doc/INSTALL.DE \
doc/MANUAL \
doc/RELEASE_NOTES \
doc/avmailgate_en.pdf \
legal/LICENSE.*
use postfix && dodoc \
doc/INSTALL.postfix
# use exim && dodoc \
# doc/INSTALL.exim
# use sendmail && dodoc \
# doc/INSTALL.sendmail
# use qmail && dodoc \
# doc/INSTALL.qmail
# use qmail && use gui && dodoc \
# doc/INSTALL.qmail.gui
doman \
doc/man/avmailgate.8 \
doc/man/avmailgate.conf.5
#
# Templates
#
diropts ""
dodir "${AVHOMEDIR}/templates.sample"
insopts ""
insinto "${AVHOMEDIR}/templates.sample"
doins \
templates/en/patho-administrator \
templates/en/patho-recipient \
templates/en/patho-sender \
templates/en/alert-administrator \
templates/en/alert-recipient \
templates/en/alert-sender
if use spamfilter; then
doins \
templates/spamfilter-subjects
fi
}
pkg_preinst() {
#
# Check for legacy files
#
# Templates: virus-* -> alert-*
for t in administrator recipient sender; do
tf="${AVHOMEDIR}/templates/virus-${t}"
new_tf="${AVHOMEDIR}/templates/alert-${t}"
if [ -e "${tf}" ]; then
ewarn
ewarn "You have an old notification mail template file in ${AVHOMEDIR}/templates/:"
ewarn " -> ${tf}"
ewarn "Please rename it as follows:"
ewarn " -> ${new_tf}"
ewarn
fi
done
}
pkg_postinst() {
#
# Config
#
echo
einfo ""
einfo "Configuration"
einfo "============="
einfo ""
einfo "Please run..."
einfo ""
einfo "\tebuild /var/db/pkg/${CATEGORY}/${PF}/${PF}.ebuild config"
einfo ""
einfo "...to configure the package!"
einfo ""
echo
}
pkg_config() {
#
# Init script
#
echo
einfo ""
einfo "Using the init script"
einfo "====================="
einfo ""
einfo "Simply run..."
einfo ""
einfo "\trc-update add antivir-mailgate default"
einfo ""
einfo "...and your're done."
einfo ""
#
# Templates
#
echo
einfo ""
einfo "Using the notification mail templates"
einfo "====================================="
einfo ""
einfo "The sample templates were installed into"
einfo ""
einfo "\t${AVHOMEDIR}/templates.sample"
einfo ""
einfo "To use them, simply do..."
einfo ""
einfo "\tcd ${AVHOMEDIR}"
einfo "\tmv templates.sample templates"
einfo ""
einfo "...and edit the files in the 'templates'-subdirectory."
einfo ""
#
# MTA config
# TODO: qmail exim sendmail
#
if use postfix; then
echo
einfo ""
einfo "MTA configuration (Postfix)"
einfo "==========================="
einfo ""
einfo "See INSTALL.postfix. Quickstart:"
einfo ""
einfo "1) Add the following line to /etc/postfix/main.cf:"
einfo ""
einfo "\tcontent_filter = smtp:127.0.0.1:10024"
einfo ""
einfo "2) Add the following line to /etc/postfix/master.cf:"
einfo ""
einfo "\tlocalhost:10025 inet n - y - - smtpd -o content_filter="
einfo ""
fi
#
# Automatic updates
# Generate a random number between 1 and 59 for the crontab
#
rand="$$$(date +%s)"
min="$[ ($rand % 59) + 1 ]"
echo
einfo ""
einfo "Using the internet updater"
einfo "=========================="
einfo ""
einfo "Add the following line to your /etc/crontab or a new file"
einfo "in /etc/cron.d/ to make AntiVir check for updates"
einfo "${min} minutes after every full hour:"
einfo ""
einfo "\t${min} * * * * root exec ${AVHOMEDIR}/avupdate --product=mailgate >/dev/null"
einfo ""
echo
}
|