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