1 |
mrness 08/10/05 08:41:29 |
2 |
|
3 |
Modified: ChangeLog metadata.xml |
4 |
Added: dspam-3.8.0-r15.ebuild |
5 |
Log: |
6 |
Add debug-bnr and debug-verbose USE flags (#237606). |
7 |
(Portage version: 2.1.4.4) |
8 |
|
9 |
Revision Changes Path |
10 |
1.123 mail-filter/dspam/ChangeLog |
11 |
|
12 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-filter/dspam/ChangeLog?rev=1.123&view=markup |
13 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-filter/dspam/ChangeLog?rev=1.123&content-type=text/plain |
14 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-filter/dspam/ChangeLog?r1=1.122&r2=1.123 |
15 |
|
16 |
Index: ChangeLog |
17 |
=================================================================== |
18 |
RCS file: /var/cvsroot/gentoo-x86/mail-filter/dspam/ChangeLog,v |
19 |
retrieving revision 1.122 |
20 |
retrieving revision 1.123 |
21 |
diff -u -r1.122 -r1.123 |
22 |
--- ChangeLog 13 Sep 2008 18:48:15 -0000 1.122 |
23 |
+++ ChangeLog 5 Oct 2008 08:41:28 -0000 1.123 |
24 |
@@ -1,6 +1,12 @@ |
25 |
# ChangeLog for mail-filter/dspam |
26 |
# Copyright 1999-2008 Gentoo Foundation; Distributed under the GPL v2 |
27 |
-# $Header: /var/cvsroot/gentoo-x86/mail-filter/dspam/ChangeLog,v 1.122 2008/09/13 18:48:15 mrness Exp $ |
28 |
+# $Header: /var/cvsroot/gentoo-x86/mail-filter/dspam/ChangeLog,v 1.123 2008/10/05 08:41:28 mrness Exp $ |
29 |
+ |
30 |
+*dspam-3.8.0-r15 (05 Oct 2008) |
31 |
+ |
32 |
+ 05 Oct 2008; Alin Năstac <mrness@g.o> metadata.xml, |
33 |
+ +dspam-3.8.0-r15.ebuild: |
34 |
+ Add debug-bnr and debug-verbose USE flags (#237606). |
35 |
|
36 |
*dspam-3.8.0-r14 (13 Sep 2008) |
37 |
|
38 |
|
39 |
|
40 |
|
41 |
1.6 mail-filter/dspam/metadata.xml |
42 |
|
43 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-filter/dspam/metadata.xml?rev=1.6&view=markup |
44 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-filter/dspam/metadata.xml?rev=1.6&content-type=text/plain |
45 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-filter/dspam/metadata.xml?r1=1.5&r2=1.6 |
46 |
|
47 |
Index: metadata.xml |
48 |
=================================================================== |
49 |
RCS file: /var/cvsroot/gentoo-x86/mail-filter/dspam/metadata.xml,v |
50 |
retrieving revision 1.5 |
51 |
retrieving revision 1.6 |
52 |
diff -u -r1.5 -r1.6 |
53 |
--- metadata.xml 20 Aug 2008 19:26:50 -0000 1.5 |
54 |
+++ metadata.xml 5 Oct 2008 08:41:28 -0000 1.6 |
55 |
@@ -11,6 +11,16 @@ |
56 |
<flag name='daemon'> |
57 |
Enable support for DSPAM to run in --daemon mode |
58 |
</flag> |
59 |
+ <flag name='debug'> |
60 |
+ Enable debugging support (don't enable this unless something needs testing!) |
61 |
+ </flag> |
62 |
+ <flag name='debug-bnr'> |
63 |
+ Activates debugging output for Bayesian Noise Reduction |
64 |
+ </flag> |
65 |
+ <flag name='debug-verbose'> |
66 |
+ Cause DSPAM produce verbose debug output and write them into LOGDIR/dspam.debug file. |
67 |
+ Never enable this for production builds! |
68 |
+ </flag> |
69 |
<flag name='large-domain'> |
70 |
Builds for large domain rather than for domain scale |
71 |
</flag> |
72 |
|
73 |
|
74 |
|
75 |
1.1 mail-filter/dspam/dspam-3.8.0-r15.ebuild |
76 |
|
77 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-filter/dspam/dspam-3.8.0-r15.ebuild?rev=1.1&view=markup |
78 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/mail-filter/dspam/dspam-3.8.0-r15.ebuild?rev=1.1&content-type=text/plain |
79 |
|
80 |
Index: dspam-3.8.0-r15.ebuild |
81 |
=================================================================== |
82 |
# Copyright 1999-2008 Gentoo Foundation |
83 |
# Distributed under the terms of the GNU General Public License v2 |
84 |
# $Header: /var/cvsroot/gentoo-x86/mail-filter/dspam/dspam-3.8.0-r15.ebuild,v 1.1 2008/10/05 08:41:28 mrness Exp $ |
85 |
|
86 |
WANT_AUTOCONF="latest" |
87 |
WANT_AUTOMAKE="latest" |
88 |
|
89 |
inherit eutils autotools multilib |
90 |
|
91 |
DESCRIPTION="A statistical-algorithmic hybrid anti-spam filter" |
92 |
HOMEPAGE="http://dspam.nuclearelephant.com/" |
93 |
SRC_URI="http://dspam.nuclearelephant.com/sources/${P}.tar.gz |
94 |
mirror://gentoo/${P}-patches-20080913.tar.gz |
95 |
http://dspam.nuclearelephant.com/sources/extras/dspam_sa_trainer.tar.gz" |
96 |
|
97 |
LICENSE="GPL-2" |
98 |
SLOT="0" |
99 |
KEYWORDS="~alpha ~amd64 ~ppc ~sparc ~x86" |
100 |
IUSE="clamav daemon ldap mysql postgres sqlite syslog \ |
101 |
large-domain virtual-users user-homedirs \ |
102 |
debug debug-bnr debug-verbose" |
103 |
|
104 |
COMMON_DEPEND="clamav? ( >=app-antivirus/clamav-0.90.2 ) |
105 |
ldap? ( >=net-nds/openldap-2.2 ) |
106 |
mysql? ( virtual/mysql ) |
107 |
sqlite? ( =dev-db/sqlite-3* )" |
108 |
DEPEND="${COMMON_DEPEND} |
109 |
postgres? ( >=virtual/postgresql-base-8 )" |
110 |
RDEPEND="${COMMON_DEPEND} |
111 |
postgres? ( || ( dev-python/psycopg >=virtual/postgresql-server-8 ) ) |
112 |
sys-process/cronbase |
113 |
virtual/logger" |
114 |
|
115 |
# some FHS-like structure |
116 |
DSPAM_HOMEDIR="/var/spool/dspam" |
117 |
DSPAM_CONFDIR="/etc/mail/dspam" |
118 |
DSPAM_LOGDIR="/var/log/dspam" |
119 |
DSPAM_MODE=2511 |
120 |
|
121 |
pkg_setup() { |
122 |
# Delete these lines some time after -r6 removal |
123 |
if has_version "<=mail-filter/dspam-3.8.0-r6" && |
124 |
built_with_use "<=mail-filter/dspam-3.8.0-r6" sqlite && |
125 |
grep -q "^StorageDriver.*libsqlite_drv.so" "${ROOT}${DSPAM_CONFDIR}"/dspam.conf; then |
126 |
eerror "Sqlite2 support has been removed. Please upgrade your database to sqlite3" |
127 |
eerror "and select libsqlite3_drv.so in dspam.conf before proceeding with update." |
128 |
die "sqlite-2 no longer supported" |
129 |
fi |
130 |
|
131 |
local egid euid |
132 |
# Need a UID and GID >= 1000, for being able to use suexec in apache |
133 |
for euid in $(seq 1000 5000 ) ; do |
134 |
[[ -z $(egetent passwd ${euid}) ]] && break |
135 |
done |
136 |
for egid in $(seq 1000 5000 ) ; do |
137 |
[[ -z $(egetent group ${egid}) ]] && break |
138 |
done |
139 |
|
140 |
enewgroup dspam ${egid} |
141 |
enewuser dspam ${euid} -1 "${DSPAM_HOMEDIR}" dspam,mail |
142 |
} |
143 |
|
144 |
src_unpack() { |
145 |
unpack ${A} |
146 |
cd "${S}" |
147 |
|
148 |
EPATCH_SUFFIX="patch" |
149 |
epatch "${WORKDIR}"/patches |
150 |
|
151 |
AT_M4DIR="${S}/m4" |
152 |
eautoreconf |
153 |
} |
154 |
|
155 |
src_compile() { |
156 |
local myconf="" |
157 |
|
158 |
if use mysql || use postgres; then |
159 |
myconf="${myconf} $(use_enable virtual-users) --enable-preferences-extension" |
160 |
if use virtual-users; then |
161 |
myconf="${myconf} --disable-homedir" |
162 |
use user-homedirs && ewarn "user-homedirs support has been disabled (not compatible with --enable-virtual-users)" |
163 |
else |
164 |
myconf="${myconf} $(use_enable user-homedirs homedir)" |
165 |
fi |
166 |
else |
167 |
myconf="${myconf} --disable-virtual-users --disable-preferences-extension \ |
168 |
$(use_enable user-homedirs homedir)" |
169 |
use virtual-users && ewarn "virtual-users support has been disabled (available only for mysql and postgres storage drivers)" |
170 |
fi |
171 |
|
172 |
if ! use syslog; then |
173 |
myconf="${myconf} --with-logfile=${DSPAM_LOGDIR}/dspam.log" |
174 |
fi |
175 |
|
176 |
local STORAGE="hash_drv" |
177 |
# select storage driver |
178 |
if use sqlite ; then |
179 |
STORAGE="${STORAGE},sqlite3_drv" |
180 |
fi |
181 |
if use mysql; then |
182 |
STORAGE="${STORAGE},mysql_drv" |
183 |
myconf="${myconf} --with-mysql-includes=/usr/include/mysql" |
184 |
myconf="${myconf} --with-mysql-libraries=/usr/$(get_libdir)/mysql" |
185 |
fi |
186 |
if use postgres ; then |
187 |
STORAGE="${STORAGE},pgsql_drv" |
188 |
myconf="${myconf} --with-pgsql-includes=/usr/include/postgresql" |
189 |
myconf="${myconf} --with-pgsql-libraries=/usr/$(get_libdir)" |
190 |
fi |
191 |
|
192 |
econf --with-storage-driver=${STORAGE} \ |
193 |
--with-dspam-home="${DSPAM_HOMEDIR}" \ |
194 |
--sysconfdir="${DSPAM_CONFDIR}" \ |
195 |
$(use_enable daemon) \ |
196 |
$(use_enable ldap) \ |
197 |
$(use_enable clamav) \ |
198 |
$(use_enable large-domain large-scale) \ |
199 |
$(use_enable !large-domain domain-scale) \ |
200 |
$(use_enable syslog) \ |
201 |
$(use_enable debug) \ |
202 |
$(use_enable debug-bnr bnr-debug) \ |
203 |
$(use_enable debug-verbose verbose-debug) \ |
204 |
--enable-long-usernames \ |
205 |
--with-dspam-group=dspam \ |
206 |
--with-dspam-home-group=dspam \ |
207 |
--with-dspam-mode=${DSPAM_MODE} \ |
208 |
--with-logdir="${DSPAM_LOGDIR}" \ |
209 |
${myconf} || die "econf failed" |
210 |
emake || die "emake failed" |
211 |
} |
212 |
|
213 |
src_install () { |
214 |
diropts -m0770 -o dspam -g dspam |
215 |
dodir "${DSPAM_CONFDIR}" |
216 |
insinto "${DSPAM_CONFDIR}" |
217 |
insopts -m640 -o dspam -g dspam |
218 |
doins src/dspam.conf |
219 |
dosym /etc/mail/dspam /etc/dspam |
220 |
|
221 |
# make install |
222 |
emake DESTDIR="${D}" install || die "emake install failed" |
223 |
|
224 |
# necessary for dovecot-dspam |
225 |
insopts -m644 |
226 |
insinto /usr/include/dspam && doins src/pref.h |
227 |
|
228 |
diropts -m0755 -o dspam -g dspam |
229 |
dodir /var/run/dspam |
230 |
|
231 |
# create logdir (used only when syslog support has been disabled or build with --enable-debug) |
232 |
if ! use syslog || use debug ; then |
233 |
diropts -m0770 -o dspam -g dspam |
234 |
dodir "${DSPAM_LOGDIR}" |
235 |
diropts -m0755 |
236 |
insinto /etc/logrotate.d |
237 |
newins "${FILESDIR}/logrotate.dspam" dspam || die "failed to install logrotate.d file" |
238 |
fi |
239 |
|
240 |
if use daemon; then |
241 |
# We use sockets for the daemon instead of tcp port 24 |
242 |
sed -e 's:^#*\(ServerDomainSocketPath[\t ]\{1,\}\).*:\1\"/var/run/dspam/dspam.sock\":gI' \ |
243 |
-e 's:^#*\(ServerPID[\t ]\{1,\}\).*:\1/var/run/dspam/dspam.pid:gI' \ |
244 |
-e 's:^#*\(ClientHost[\t ]\{1,\}\)/.*:\1\"/var/run/dspam/dspam.sock\":gI' \ |
245 |
-i "${D}/${DSPAM_CONFDIR}/dspam.conf" |
246 |
|
247 |
newinitd "${FILESDIR}/dspam.rc" dspam || die "failed to install init script" |
248 |
|
249 |
fowners root:dspam /usr/bin/dspamc && |
250 |
fperms u=rx,g=xs,o=x /usr/bin/dspamc || |
251 |
die "failed to alter dspamc owner:group or mode" |
252 |
fi |
253 |
|
254 |
# database related configuration and scripts |
255 |
local PASSWORD="${RANDOM}${RANDOM}${RANDOM}${RANDOM}" DSPAM_DB_DATA=() |
256 |
if use sqlite; then |
257 |
insinto "${DSPAM_CONFDIR}" |
258 |
newins src/tools.sqlite_drv/purge-3.sql sqlite3_purge.sql || die "failed to install sqlite3_purge.sql script" |
259 |
fi |
260 |
if use mysql; then |
261 |
DSPAM_DB_DATA[0]="/var/run/mysqld/mysqld.sock" |
262 |
DSPAM_DB_DATA[1]="" |
263 |
DSPAM_DB_DATA[2]="dspam" |
264 |
DSPAM_DB_DATA[3]="${PASSWORD}" |
265 |
DSPAM_DB_DATA[4]="dspam" |
266 |
DSPAM_DB_DATA[5]="false" |
267 |
|
268 |
# Activate mysql database configuration |
269 |
sed -e "s:^#*\(MySQLServer[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[0]}:gI" \ |
270 |
-e "s:^#*\(MySQLPort[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[1]}:gI" \ |
271 |
-e "s:^#*\(MySQLUser[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[2]}:gI" \ |
272 |
-e "s:^#*\(MySQLPass[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[3]}:gI" \ |
273 |
-e "s:^#*\(MySQLDb[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[4]}:gI" \ |
274 |
-e "s:^#*\(MySQLCompress[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[5]}:gI" \ |
275 |
-i "${D}/${DSPAM_CONFDIR}/dspam.conf" |
276 |
|
277 |
insinto "${DSPAM_CONFDIR}" |
278 |
newins src/tools.mysql_drv/mysql_objects-space.sql mysql_objects-space.sql && |
279 |
newins src/tools.mysql_drv/mysql_objects-speed.sql mysql_objects-speed.sql && |
280 |
newins src/tools.mysql_drv/mysql_objects-4.1.sql mysql_objects-4.1.sql && |
281 |
newins src/tools.mysql_drv/purge.sql mysql_purge.sql && |
282 |
newins src/tools.mysql_drv/purge-4.1.sql mysql_purge-4.1.sql || |
283 |
die "failed to install mysql*.sql scripts" |
284 |
if use virtual-users ; then |
285 |
newins src/tools.mysql_drv/virtual_users.sql mysql_virtual_users.sql && |
286 |
newins src/tools.mysql_drv/virtual_user_aliases.sql mysql_virtual_user_aliases.sql || |
287 |
die "failed to install mysql_virtual_user*.sql scripts" |
288 |
fi |
289 |
fi |
290 |
if use postgres ; then |
291 |
DSPAM_DB_DATA[0]="127.0.0.1" |
292 |
DSPAM_DB_DATA[1]="5432" |
293 |
DSPAM_DB_DATA[2]="dspam" |
294 |
DSPAM_DB_DATA[3]="${PASSWORD}" |
295 |
DSPAM_DB_DATA[4]="dspam" |
296 |
|
297 |
# Activate pgsql database configuration |
298 |
sed -e "s:^#*\(PgSQLServer[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[0]}:gI" \ |
299 |
-e "s:^#*\(PgSQLPort[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[1]}:gI" \ |
300 |
-e "s:^#*\(PgSQLUser[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[2]}:gI" \ |
301 |
-e "s:^#*\(PgSQLPass[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[3]}:gI" \ |
302 |
-e "s:^#*\(PgSQLDb[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[4]}:gI" \ |
303 |
-e "s:^#*\(PgSQLConnectionCache[\t ]*.\):\1:gI" \ |
304 |
-i "${D}/${DSPAM_CONFDIR}"/dspam.conf |
305 |
|
306 |
insinto "${DSPAM_CONFDIR}" |
307 |
newins src/tools.pgsql_drv/pgsql_objects.sql pgsql_objects.sql && |
308 |
newins src/tools.pgsql_drv/purge.sql pgsql_purge.sql || |
309 |
die "failed to install pgsql*.sql scripts" |
310 |
if use virtual-users ; then |
311 |
newins src/tools.pgsql_drv/virtual_users.sql pgsql_virtual_users.sql || |
312 |
die "failed to install pgsql_virtual_users.sql scripts" |
313 |
fi |
314 |
|
315 |
# Install psycopg scripts needed when postgresql is not installed |
316 |
exeinto "${DSPAM_CONFDIR}" |
317 |
doexe "${FILESDIR}"/pgsql_{createdb,purge}.py || die "failed to install psycopg scripts" |
318 |
fi |
319 |
|
320 |
# Set default storage |
321 |
local DEFAULT_STORAGE |
322 |
if use sqlite ; then |
323 |
DEFAULT_STORAGE=sqlite3 |
324 |
elif use mysql ; then |
325 |
DEFAULT_STORAGE=mysql |
326 |
elif use postgres ; then |
327 |
DEFAULT_STORAGE=pgsql |
328 |
fi |
329 |
if [[ -z "${DEFAULT_STORAGE}" ]]; then |
330 |
# When only one storage driver is compiled, it is linked statically with dspam |
331 |
# thus you should not set the StorageDriver at all |
332 |
# Also, hash_drv requires certain tokenizer and PValue (see bug #185718) |
333 |
sed -e "s:^\(StorageDriver[\t ].*\)$:#\1:" \ |
334 |
-e "s:^Tokenizer .*$:Tokenizer sbph:" \ |
335 |
-e "/^#PValue/d" \ |
336 |
-e "s:^PValue .*$:PValue markov:" \ |
337 |
-i "${D}/${DSPAM_CONFDIR}"/dspam.conf |
338 |
else |
339 |
# Set the storage driver and use purge configuration for SQL-based installations |
340 |
sed -e "s:^\(Purge.*\):###\1:g" \ |
341 |
-e "s:^#\(Purge.*\):\1:g" \ |
342 |
-e "s:^###\(Purge.*\):#\1:g" \ |
343 |
-e "s:^\(StorageDriver[\t ].*\)libhash_drv.so:\1lib${DEFAULT_STORAGE}_drv.so:" \ |
344 |
-i "${D}/${DSPAM_CONFDIR}"/dspam.conf |
345 |
fi |
346 |
|
347 |
# installs the notification messages |
348 |
# -> The documentation is wrong! The files need to be in ./txt |
349 |
echo "Scanned and tagged as SPAM with DSPAM ${PV} by Your ISP.com">"${T}"/msgtag.spam |
350 |
echo "Scanned and tagged as non-SPAM with DSPAM ${PV} by Your ISP.com">"${T}"/msgtag.nonspam |
351 |
insinto "${DSPAM_CONFDIR}"/txt |
352 |
doins "${S}"/txt/*.txt |
353 |
doins "${T}"/msgtag.* |
354 |
|
355 |
# Create the opt-in / opt-out directories |
356 |
diropts -m0770 -o dspam -g dspam |
357 |
dodir "${DSPAM_HOMEDIR}" |
358 |
keepdir "${DSPAM_HOMEDIR}"/opt-in |
359 |
keepdir "${DSPAM_HOMEDIR}"/opt-out |
360 |
diropts -m0755 |
361 |
|
362 |
# dspam cron job |
363 |
exeinto /etc/cron.daily |
364 |
newexe "${FILESDIR}/dspam.cron-r3" dspam.cron || die "failed to install cron script" |
365 |
|
366 |
# documentation |
367 |
dodoc CHANGELOG README* RELEASE.NOTES UPGRADING |
368 |
docinto doc |
369 |
dodoc doc/*.txt |
370 |
docinto gentoo |
371 |
dodoc "${FILESDIR}"/README.{postfix,qmail} |
372 |
docinto sa_train |
373 |
dodoc "${WORKDIR}"/dspam_sa_trainer/* |
374 |
doman man/dspam* |
375 |
} |
376 |
|
377 |
pkg_preinst() { |
378 |
# Delete these lines some time after -r6 removal |
379 |
if has_version "<=mail-filter/dspam-3.8.0-r6" ; then |
380 |
# Remove obsolete *.data files |
381 |
local f |
382 |
for f in "${ROOT}${DSPAM_CONFDIR}"/{mysql,pgsql}.data ; do |
383 |
f=${f/\/\//\/} |
384 |
if [[ -f "${f}" ]]; then |
385 |
rm "${f}" && |
386 |
elog "Obsolete ${f} has been removed" || |
387 |
eerror "Failed to remove ${f}" |
388 |
fi |
389 |
done |
390 |
fi |
391 |
} |
392 |
|
393 |
pkg_postinst() { |
394 |
ewarn "The hash_drv storage backend has the following requirements:" |
395 |
ewarn " - PValue must be set to 'markov'; Do not use this pvalue with any other storage backend!" |
396 |
ewarn " - Tokenizer must be either 'sbph' or 'osb'" |
397 |
ewarn "See markov.txt for more info." |
398 |
|
399 |
if use mysql || use postgres; then |
400 |
elog |
401 |
elog "To setup DSPAM to run out-of-the-box on your system with a MySQL" |
402 |
elog "or PostgreSQL database, run:" |
403 |
elog "emerge --config =${PF}" |
404 |
fi |
405 |
|
406 |
if use daemon; then |
407 |
elog |
408 |
elog "If you want to run DSPAM in the new daemon mode remember" |
409 |
elog "to make the DSPAM daemon start during boot:" |
410 |
elog " rc-update add dspam default" |
411 |
elog |
412 |
elog "To use the DSPAM daemon mode, the used storage driver must be thread-safe." |
413 |
fi |
414 |
|
415 |
elog |
416 |
elog "See http://dspamwiki.expass.de/Installation for more info" |
417 |
} |
418 |
|
419 |
# Edits interactively one or more parameters from "${ROOT}${DSPAM_CONFDIR}/dspam.conf" |
420 |
# Usage: edit_dspam_params param_name1 [param_name2 ..] |
421 |
edit_dspam_params() { |
422 |
local PARAMETER OLD_VALUE VALUE |
423 |
for PARAMETER in $@ ; do |
424 |
OLD_VALUE=$(awk "BEGIN { IGNORECASE=1; } \$1==\"${PARAMETER}\" { print \$2; exit; }" "${ROOT}${DSPAM_CONFDIR}/dspam.conf") |
425 |
[[ $? == 0 ]] || return 1 |
426 |
if [[ "${PARAMETER}" == *"Pass" ]]; then |
427 |
read -r -p "${PARAMETER} (default ${OLD_VALUE:-none}; enter random for generating a new random password): " VALUE |
428 |
[[ "${VALUE}" == "random" ]] && VALUE="${RANDOM}${RANDOM}${RANDOM}${RANDOM}" |
429 |
else |
430 |
read -r -p "${PARAMETER} (default ${OLD_VALUE:-none}): " VALUE |
431 |
fi |
432 |
|
433 |
if [[ -z "${VALUE}" ]] ; then |
434 |
VALUE=${OLD_VALUE} |
435 |
else |
436 |
sed -e "s:^#*${PARAMETER}\([\t ].*\)\?\$:${PARAMETER} ${VALUE}:gI" \ |
437 |
-i "${ROOT}${DSPAM_CONFDIR}/dspam.conf" |
438 |
[[ $? == 0 ]] || return 2 |
439 |
fi |
440 |
eval $PARAMETER=\"${VALUE}\" |
441 |
done |
442 |
return 0 |
443 |
} |
444 |
|
445 |
# Selects the storage driver in "${ROOT}${DSPAM_CONFDIR}/dspam.conf" |
446 |
# usage: set_storage_driver { hash | sqlite3 | mysql | pgsql } |
447 |
set_storage_driver() { |
448 |
sed -e "s:^[#\t ]*\(StorageDriver[\t ].*\)lib[a-z1-9]\+_drv.so:\1lib${1}_drv.so:" \ |
449 |
-i "${ROOT}${DSPAM_CONFDIR}"/dspam.conf && |
450 |
einfo "Storage driver lib${1}_drv.so has been selected" |
451 |
} |
452 |
|
453 |
pkg_config () { |
454 |
local AVAIL_BACKENDS=( hash ) |
455 |
use sqlite && AVAIL_BACKENDS=( ${AVAIL_BACKENDS[*]} sqlite ) |
456 |
use mysql && AVAIL_BACKENDS=( ${AVAIL_BACKENDS[*]} mysql ) |
457 |
use postgres && AVAIL_BACKENDS=( ${AVAIL_BACKENDS[*]} postgres ) |
458 |
local USE_BACKEND |
459 |
read -p "Which backend do you want to configure? (available backends are ${AVAIL_BACKENDS[*]}): " USE_BACKEND |
460 |
if [[ " ${AVAIL_BACKENDS[*]} " != *" ${USE_BACKEND} "* ]]; then |
461 |
eerror "The '${USE_BACKEND}' backend is not available." |
462 |
return 1 |
463 |
fi |
464 |
|
465 |
case "${USE_BACKEND}" in |
466 |
|
467 |
hash) |
468 |
einfo "hash driver will automatically create the necessary databases" |
469 |
set_storage_driver hash |
470 |
;; |
471 |
|
472 |
sqlite) |
473 |
einfo "sqlite driver will automatically create the necessary databases" |
474 |
set_storage_driver sqlite3 |
475 |
;; |
476 |
|
477 |
mysql) |
478 |
local MySQLServer MySQLPort MySQLUser MySQLPass MySQLDb MySQLCompress |
479 |
edit_dspam_params MySQLServer MySQLPort MySQLUser MySQLPass MySQLDb MySQLCompress || return $? |
480 |
if [[ -z "${MySQLServer}" || -z "${MySQLUser}" || -z "${MySQLPass}" || -z "${MySQLDb}" ]]; then |
481 |
eerror "Following parameters are required: MySQLServer MySQLUser MySQLPass MySQLDb" |
482 |
return 1 |
483 |
fi |
484 |
|
485 |
local MySQL_DB_Type MySQL_Virtuser_Type |
486 |
einfo " Please select what kind of database you like to create:" |
487 |
einfo " [0] Don't create the database, I will do it myself" |
488 |
einfo " [1] Database will be hosted on a mysql-4.1 server or above" |
489 |
einfo " [2] Space optimized database on a mysql-4.0 server or below" |
490 |
einfo " [3] Speed optimized database on a mysql-4.0 server or below" |
491 |
einfo |
492 |
while read -n 1 -s -p " Press 0, 1, 2 or 3 on the keyboard to select database " MySQL_DB_Type; do |
493 |
if [[ "${MySQL_DB_Type}" == "0" ]] ; then |
494 |
echo |
495 |
set_storage_driver mysql |
496 |
return 0 |
497 |
fi |
498 |
[[ "${MySQL_DB_Type}" == "1" || "${MySQL_DB_Type}" == "2" || "${MySQL_DB_Type}" == "3" ]] && echo && break |
499 |
done |
500 |
if use virtual-users ; then |
501 |
einfo " Please select what kind of virtual_uids table you like to use:" |
502 |
einfo " [1] Virtual users added automatically (use it if this server is the primary MX)" |
503 |
einfo " [2] Virtual users added manually (use it if this server is a secondary MX)" |
504 |
einfo |
505 |
while read -n 1 -s -p " Press 1 or 2 on the keyboard to select table type " MySQL_Virtuser_Type; do |
506 |
[[ "${MySQL_Virtuser_Type}" == "1" || "${MySQL_Virtuser_Type}" == "2" ]] && echo && break |
507 |
done |
508 |
fi |
509 |
|
510 |
local MYSQL_ROOT_USER |
511 |
read -r -p "Your administrative MySQL account (default root): " MYSQL_ROOT_USER |
512 |
if [[ -z "${MYSQL_ROOT_USER}" ]]; then |
513 |
MYSQL_ROOT_USER="root" |
514 |
fi |
515 |
einfo "When prompted for a password, please enter your MySQL ${MYSQL_ROOT_USER} password" |
516 |
|
517 |
local MYSQL_CMD_LINE="/usr/bin/mysql -u ${MYSQL_ROOT_USER} -p" |
518 |
[[ "${MySQLServer}" != "/"* ]] && MYSQL_CMD_LINE="${MYSQL_CMD_LINE} -h ${MySQLServer}" |
519 |
[[ -n "${MySQLPort}" ]] && MYSQL_CMD_LINE="${MYSQL_CMD_LINE} -P ${MySQLPort}" |
520 |
{ |
521 |
echo "CREATE DATABASE ${MySQLDb};" |
522 |
echo "USE ${MySQLDb};" |
523 |
case ${MySQL_DB_Type} in |
524 |
1) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_objects-4.1.sql ;; |
525 |
2) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_objects-space.sql ;; |
526 |
3) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_objects-speed.sql ;; |
527 |
esac |
528 |
if use virtual-users ; then |
529 |
case ${MySQL_Virtuser_Type} in |
530 |
1) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_virtual_users.sql ;; |
531 |
2) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_virtual_user_aliases.sql ;; |
532 |
esac |
533 |
fi |
534 |
echo "GRANT SELECT,INSERT,UPDATE,DELETE ON ${MySQLDb}.* TO '${MySQLUser}'@'%' IDENTIFIED BY '${MySQLPass}';" |
535 |
echo "FLUSH PRIVILEGES;" |
536 |
} | ${MYSQL_CMD_LINE} |
537 |
[[ ${PIPESTATUS[1]} == 0 ]] || return ${PIPESTATUS[1]} |
538 |
|
539 |
einfo "MySQL database created successfully" |
540 |
set_storage_driver mysql |
541 |
;; |
542 |
|
543 |
postgres) |
544 |
local PgSQLServer PgSQLPort PgSQLUser PgSQLPass PgSQLDb |
545 |
edit_dspam_params PgSQLServer PgSQLPort PgSQLUser PgSQLPass PgSQLDb || return $? |
546 |
if [[ -z "${PgSQLServer}" || -z "${PgSQLUser}" || -z "${PgSQLPass}" || -z "${PgSQLDb}" ]]; then |
547 |
eerror "Following parameters are required: PgSQLServer PgSQLUser PgSQLPass PgSQLDb" |
548 |
return 1 |
549 |
fi |
550 |
|
551 |
local PgSQL_DB_Create |
552 |
einfo " Do you want PgSQL database be automatically created for you?" |
553 |
while read -n 1 -s -p " Press y or n " PgSQL_DB_Create; do |
554 |
if [[ "${PgSQL_DB_Create}" == "n" || "${PgSQL_DB_Create}" == "N" ]] ; then |
555 |
echo |
556 |
set_storage_driver pgsql |
557 |
return 0 |
558 |
fi |
559 |
[[ "${PgSQL_DB_Create}" == "y" || "${PgSQL_DB_Create}" == "Y" ]] && echo && break |
560 |
done |
561 |
|
562 |
local PGSQL_ROOT_USER |
563 |
read -r -p "Your administrative PgSQL account (default postgres): " PGSQL_ROOT_USER |
564 |
if [[ -z "${PGSQL_ROOT_USER}" ]]; then |
565 |
PGSQL_ROOT_USER="postgres" |
566 |
fi |
567 |
einfo "When prompted for a password, please enter your PgSQL ${PGSQL_ROOT_USER} password" |
568 |
|
569 |
if [[ -x /usr/bin/psql ]]; then |
570 |
# Create database using psql |
571 |
local PGSQL_CMD_LINE="/usr/bin/psql -h ${PgSQLServer}" |
572 |
[[ -n "${PgSQLPort}" ]] && PGSQL_CMD_LINE="${PGSQL_CMD_LINE} -p ${PgSQLPort}" |
573 |
|
574 |
{ |
575 |
echo "\\set ON_ERROR_STOP = on;" |
576 |
echo "CREATE USER ${PgSQLUser} WITH PASSWORD '${PgSQLPass}' NOCREATEDB NOCREATEUSER;" |
577 |
echo "CREATE DATABASE ${PgSQLDb};" |
578 |
echo "GRANT ALL PRIVILEGES ON DATABASE ${PgSQLDb} TO ${PgSQLUser};" |
579 |
echo "GRANT ALL PRIVILEGES ON SCHEMA public TO ${PgSQLUser};" |
580 |
echo "UPDATE pg_database SET datdba=(SELECT usesysid FROM pg_shadow WHERE usename='${PgSQLUser}') WHERE datname='${PgSQLDb}';" |
581 |
echo "\\c ${PgSQLDb};" |
582 |
echo "CREATE FUNCTION plpgsql_call_handler() RETURNS language_handler AS '\$libdir/plpgsql', 'plpgsql_call_handler' LANGUAGE c;" |
583 |
echo "CREATE FUNCTION plpgsql_validator(oid) RETURNS void AS '\$libdir/plpgsql', 'plpgsql_validator' LANGUAGE c;" |
584 |
echo "CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql HANDLER plpgsql_call_handler VALIDATOR plpgsql_validator;" |
585 |
} | ${PGSQL_CMD_LINE} -d template1 -U ${PGSQL_ROOT_USER} |
586 |
[[ ${PIPESTATUS[1]} == 0 ]] || return ${PIPESTATUS[1]} |
587 |
|
588 |
{ |
589 |
echo "\\set ON_ERROR_STOP = on;" |
590 |
cat "${ROOT}${DSPAM_CONFDIR}"/pgsql_objects.sql |
591 |
use virtual-users && cat "${ROOT}${DSPAM_CONFDIR}"/pgsql_virtual_users.sql |
592 |
} | PGUSER="${PgSQLUser}" PGPASSWORD="${PgSQLPass}" ${PGSQL_CMD_LINE} -d "${PgSQLDb}" -U ${PgSQLUser} |
593 |
[[ ${PIPESTATUS[1]} == 0 ]] || return ${PIPESTATUS[1]} |
594 |
else |
595 |
# Create database using psycopg script |
596 |
if use virtual-users ; then |
597 |
DSPAM_PgSQLPass="${PgSQLPass}" "${ROOT}${DSPAM_CONFDIR}"/pgsql_createdb.py "${PgSQLServer}" "${PgSQLPort}" "${PGSQL_ROOT_USER}" \ |
598 |
"${PgSQLUser}" "${PgSQLDb}" "${ROOT}${DSPAM_CONFDIR}"/pgsql_objects.sql "${ROOT}${DSPAM_CONFDIR}"/pgsql_virtual_users.sql |
599 |
else |
600 |
DSPAM_PgSQLPass="${PgSQLPass}" "${ROOT}${DSPAM_CONFDIR}"/pgsql_createdb.py "${PgSQLServer}" "${PgSQLPort}" "${PGSQL_ROOT_USER}" \ |
601 |
"${PgSQLUser}" "${PgSQLDb}" "${ROOT}${DSPAM_CONFDIR}"/pgsql_objects.sql |
602 |
fi |
603 |
[[ $? == 0 ]] || return $? |
604 |
fi |
605 |
|
606 |
einfo "PgSQL database created successfully" |
607 |
set_storage_driver pgsql |
608 |
;; |
609 |
|
610 |
esac |
611 |
} |