Portage is a package management system used by Gentoo Linux
# ChangeLog for mail-filter/dspam
# Copyright 1999-2008 Gentoo Foundation; Distributed under the GPL v2
# $Header: /var/cvsroot/gentoo-x86/mail-filter/dspam/ChangeLog,v 1.118 2008/07/15 06:05:12 mrness Exp $
*dspam-3.8.0-r12 (15 Jul 2008)
15 Jul 2008; Alin Năstac
Add StripRcptDomain option, thanks to Sven Schwyn
(#231175).
08 Jun 2008; Alin Năstac
-files/dspam.cron-r2, -dspam-3.8.0-r7.ebuild, -dspam-3.8.0-r8.ebuild,
-dspam-3.8.0-r9.ebuild, -dspam-3.8.0-r10.ebuild:
Remove obsolete revisions.
05 Jun 2008; Friedrich Oslage
dspam-3.8.0-r11.ebuild:
sparc stable, bug 224169
01 Jun 2008; Alin Năstac
Correct pgsql libdir (#224169).
30 May 2008; Christian Faulhammer
dspam-3.8.0-r11.ebuild:
stable x86, bug 224169
29 May 2008; Alin Năstac
Drop bindnow-flags.
21 May 2008; Tiziano Müller
dspam-3.8.0-r8.ebuild, dspam-3.8.0-r9.ebuild, dspam-3.8.0-r10.ebuild,
dspam-3.8.0-r11.ebuild:
Changed dependency for postgresql from dev-db/postgresql to
virtual/postgresql-server
19 May 2008; Tiziano Müller
dspam-3.8.0-r8.ebuild, dspam-3.8.0-r9.ebuild, dspam-3.8.0-r10.ebuild,
dspam-3.8.0-r11.ebuild:
Changed dependency for postgresql to virtual/postgresql-base
20 Apr 2008; Richard Freeman
amd64 stable - 211398
*dspam-3.8.0-r11 (20 Jan 2008)
20 Jan 2008; Alin Năstac
+dspam-3.8.0-r11.ebuild:
Run dspam_logrotate on home dir for purging the system.log.
*dspam-3.8.0-r10 (16 Jan 2008)
16 Jan 2008; Alin Năstac
files/logrotate.dspam, +dspam-3.8.0-r10.ebuild:
Cron job and log fixes (#205923).
31 Dec 2007; Alin Năstac
Fix dspam-web graphs by correcting 14_all_cgi-fixes patch.
12 Dec 2007; Alin Năstac
Fix unused variables warnings, thanks to a steveb's improvement to
make-daemon-quiet.patch .
*dspam-3.8.0-r9 (11 Dec 2007)
11 Dec 2007; Alin Năstac
+dspam-3.8.0-r9.ebuild:
Correctly lock hash database at cssclean startup and remove useless
csscompress (#201656). Fix segfault, thanks to steveb
(#199700).
*dspam-3.8.0-r8 (22 Nov 2007)
22 Nov 2007; Alin Năstac
Add steveb's improvements (#199428).
12 Nov 2007; Alin Năstac
-dspam-3.8.0-r6.ebuild:
Remove obsolete revision.
05 Nov 2007; Raúl Porcel
sparc stable wrt #196753
04 Nov 2007; Alin Năstac
Remove useless create_dspam_usergroup call from pkg_postinst.
22 Oct 2007; Alin Năstac
Stable on x86.
02 Oct 2007; Alin Năstac
Add syslog use-flag and sanitize flags processing.
*dspam-3.8.0-r7 (30 Sep 2007)
30 Sep 2007; Alin Năstac
+files/pgsql_createdb.py, +files/pgsql_purge.py, +dspam-3.8.0-r7.ebuild:
Major dspam.cron and pkg_config redesign (#193081). Drop sqlite-2 support.
Install pref.h needed by dovecot-dspam.
*dspam-3.8.0-r6 (10 Sep 2007)
10 Sep 2007; Alin Năstac
-dspam-3.8.0-r5.ebuild, +dspam-3.8.0-r6.ebuild:
Use Postgres command vacuumdb --analyse instead --full (#191271).
*dspam-3.8.0-r5 (09 Sep 2007)
09 Sep 2007; Alin Năstac
+dspam-3.8.0-r5.ebuild:
Don't vacuum the postgres database in purge sql script because it will be
vacuumed anyway in cron script (#191271).
*dspam-3.8.0-r4 (17 Aug 2007)
17 Aug 2007; Alin Năstac
-dspam-3.8.0-r3.ebuild, +dspam-3.8.0-r4.ebuild:
Improve cron script, thanks to steveb
*dspam-3.8.0-r3 (19 Jul 2007)
19 Jul 2007; Alin Năstac
+dspam-3.8.0-r3.ebuild:
Always install hash storage backend and add ewarns about how to use it
(#185718).
*dspam-3.8.0-r2 (08 Jul 2007)
08 Jul 2007; Alin Năstac
files/dspam.cron, -dspam-3.8.0-r1.ebuild, +dspam-3.8.0-r2.ebuild:
Fix sqlite part of cron script, thanks to Henry So
(#184194).
24 Jun 2007; Alin Năstac
dspam-3.8.0-r1.ebuild:
Remove obsolete version. Fix QA notice and add warning in pkg_setup about
hash backend (#179400).
13 Jun 2007; Joshua Jackson
Stable x86
22 May 2007; Gustavo Zacarias
Stable on sparc wrt #179400
*dspam-3.8.0-r1 (18 Apr 2007)
18 Apr 2007; Alin Năstac
+dspam-3.8.0-r1.ebuild:
Install storage drivers in $(libdir)/dspam (bug #172756 comment #3). Use
get_libdir() for mysql and postgresql library paths. Re-add qa-fixes patch
renamed as ldap-deprecated.
*dspam-3.8.0 (17 Apr 2007)
17 Apr 2007; Alin Năstac
+dspam-3.8.0.ebuild:
Version bump, thanks to steveb
Copa
03 Apr 2007; Gustavo Zacarias
Stable on sparc wrt #172756
30 Mar 2007; Alin Năstac
dspam-3.6.8-r3.ebuild:
Stable on x86 (#172756).
*dspam-3.6.8-r3 (22 Mar 2007)
22 Mar 2007; Alin Năstac
Select administrative mysql account used to initialize the database
(#171711). When daemon flag is enabled: install dspamc executable with sgid
and group dspam (#171725); set the default ClientHost to the default value
of ServerDomainSocketPath (#171726).
19 Mar 2007; Bryan Østergaard
Remove st_lim from metadata.xml due to retirement.
18 Mar 2007; Marius Mauch
Replacing einfo with elog
18 Feb 2007; Alin Năstac
Move the code that preserve *.data files to pkg_preinst (#167285).
*dspam-3.6.8-r2 (08 Jan 2007)
08 Jan 2007; Alin Năstac
-dspam-3.6.8-r1.ebuild, +dspam-3.6.8-r2.ebuild:
Fixes and improvements suggested in bug #158702.
*dspam-3.6.8-r1 (19 Dec 2006)
19 Dec 2006; Alin Năstac
-dspam-3.6.6.ebuild, -dspam-3.6.8.ebuild, +dspam-3.6.8-r1.ebuild:
Remove obsolete version. Improve pkg_config and cron script (#158194 and
#158227).
23 Nov 2006; Francesco Riosa
dspam-3.6.8.ebuild:
dev-db/mysql => virtual/mysql
*dspam-3.6.8 (29 Oct 2006)
29 Oct 2006; Alin Nastac
-files/crontab.mysql, metadata.xml, -dspam-3.2.7.ebuild,
-dspam-3.4.9.ebuild, -dspam-3.6.0.ebuild, -dspam-3.6.1.ebuild,
-dspam-3.6.2.ebuild, -dspam-3.6.3.ebuild, -dspam-3.6.4.ebuild,
-dspam-3.6.5.ebuild, +dspam-3.6.8.ebuild:
Add myself as maintainer. Version bump, with most Debian patches applied
(#135917). Fix dspam executable permissions (#128024). Remove obsolete
versions.
23 Aug 2006; Jason Wever
Added ~sparc keyword wrt bug #144545.
05 Jun 2006; Lim Swee Tat
Fixes by mr_bones. Nothing added by st_lim. Apologies
14 Feb 2006; Lim Swee Tat
digest error
*dspam-3.6.4 (13 Feb 2006)
13 Feb 2006; Lim Swee Tat
+dspam-3.6.4.ebuild:
Version bump 3.6.4
*dspam-3.6.3 (20 Jan 2006)
20 Jan 2006; Lim Swee Tat
Version bump - Upgrade NOW!
08 Jan 2006; Renat Lumpau
dspam-3.4.9.ebuild, dspam-3.6.0.ebuild, dspam-3.6.1.ebuild,
dspam-3.6.2.ebuild:
Fixed emerge --config wrt bug #109482.
*dspam-3.6.2 (01 Dec 2005)
01 Dec 2005; Lim Swee Tat
Version bump - Maintenance release
20 Nov 2005; Stefan Briesenick
dspam-3.6.1.ebuild:
added missing 'sqlite3' use-flag.
16 Nov 2005; Lim Swee Tat
Patched for bug #112627
*dspam-3.6.1 (09 Nov 2005)
09 Nov 2005; Lim Swee Tat
Version bump
06 Nov 2005; Lim Swee Tat
Fixed bug #81596. Late. :(
05 Nov 2005; Lim Swee Tat
Added sqlite3 as a use flag, and removed older stuff
05 Nov 2005; Lim Swee Tat
Enabling sqlite3 again
05 Nov 2005; Lim Swee Tat
Added use flag for clamav
*dspam-3.6.0 (17 Oct 2005)
17 Oct 2005; Lim Swee Tat
Version bump
*dspam-3.6_rc3 (15 Oct 2005)
15 Oct 2005; Lim Swee Tat
Version bump long overdue. :)
*dspam-3.6_rc1 (23 Sep 2005)
23 Sep 2005; Lim Swee Tat
+dspam-3.6_rc1.ebuild:
Version bump to 3.6_rc1
15 Sep 2005;
Marked ~amd64
29 Aug 2005; Tom Martin
Added in a conditional dependency with (another) local logrotate USE flag.
Resolves bug #97447.
*dspam-3.4.9 (08 Aug 2005)
08 Aug 2005; Lim Swee Tat
-dspam-3.4.0-r1.ebuild, -dspam-3.4.1.ebuild, -dspam-3.4.2.ebuild,
-dspam-3.4.5.ebuild, -dspam-3.4.6.ebuild, +dspam-3.4.9.ebuild:
Version bump.
17 Jun 2005; Lim Swee Tat
Version bump long overdue.
11 May 2005; Lim Swee Tat
Removed the daemon use flag
*dspam-3.4.6 (10 May 2005)
10 May 2005; Lim Swee Tat
dspam-3.4.1.ebuild, dspam-3.4.2.ebuild, dspam-3.4.5.ebuild,
+dspam-3.4.6.ebuild:
Fixed 88246 and 89740
*dspam-3.4.6 (10 May 2005)
10 May 2005; Lim Swee Tat
dspam-3.4.1.ebuild, dspam-3.4.2.ebuild, dspam-3.4.5.ebuild,
+dspam-3.4.6.ebuild:
Version bump
*dspam-3.4.5 (27 Apr 2005)
27 Apr 2005; Lim Swee Tat
Version bump
*dspam-3.4.2 (05 Apr 2005)
05 Apr 2005; Lim Swee Tat
Version bump
05 Apr 2005; Lim Swee Tat
Fixed bug #87358 and #85939
28 Mar 2005; Lim Swee Tat
Fixed bug #86099
*dspam-3.4.1 (23 Mar 2005)
23 Mar 2005; Lim Swee Tat
+dspam-3.4.1.ebuild:
Added 3.4.1, fixed virtual users.sql
*dspam-3.4.0-r1 (20 Mar 2005)
20 Mar 2005; Lim Swee Tat
+files/dspam.rc, +dspam-3.4.0-r1.ebuild:
Fix bug #85939 and #81596
*dspam-3.4_rc3 (11 Mar 2005)
11 Mar 2005; Lim Swee Tat
+dspam-3.4_rc3.ebuild:
Fixed 3 birds, uh bugs with one stone - Bugs #84539, #81345, #78727
09 Mar 2005; Lim Swee Tat
-dspam-3.2.6.ebuild, -dspam-3.3.11.ebuild, -dspam-3.3.8.ebuild,
-dspam-3.4_beta1.ebuild, -dspam-3.4_beta2.ebuild, -dspam-3.4_beta3.ebuild,
-dspam-3.4_rc1.ebuild:
Removed the older files/Housekeeping
09 Mar 2005; Lim Swee Tat
dspam-3.4_rc2.ebuild:
Fixed bug #83779. Documents were overwritting. Thanx to mike@nerone.org
*dspam-3.4_rc1 (04 Mar 2005)
04 Mar 2005; Ciaran McCreesh
dspam-3.2.6.ebuild, dspam-3.2.7.ebuild, dspam-3.3.11.ebuild,
dspam-3.3.8.ebuild, dspam-3.4_beta1.ebuild, dspam-3.4_beta2.ebuild,
dspam-3.4_beta3.ebuild, dspam-3.4_rc1.ebuild, dspam-3.4_rc2.ebuild:
Move sys-apps/cronbase -> sys-process/cronbase
*dspam-3.4_rc2 (01 Mar 2005)
01 Mar 2005; Lim Swee Tat
Version bump. Need to include an init.d daemon for the --enable-daemon option.
*dspam-3.4_beta3 (17 Feb 2005)
17 Feb 2005; Lim Swee Tat
Version bump
*dspam-3.4_beta2 (08 Feb 2005)
08 Feb 2005; Lim Swee Tat
+dspam-3.4_beta2.ebuild:
Version bump
*dspam-3.4_beta1 (21 Jan 2005)
21 Jan 2005; Lim Swee Tat
dspam-3.2.6.ebuild, dspam-3.3.11.ebuild, dspam-3.3.8.ebuild,
dspam-3.4_beta1.ebuild:
Trying to fix bug #78768
Changing dspam to a userid of 26, one after 25.
20 Jan 2005; Lim Swee Tat
Added courier as a dependency for maildrop
*dspam-3.2.6 (20 Jan 2005)
20 Jan 2005; Lim Swee Tat
+dspam-3.2.6.ebuild:
Version bump
17 Jan 2005; Lim Swee Tat
Removing 3.3.11, bad packaging upstream
Version bump to beta1
*dspam-3.3.11 (14 Jan 2005)
14 Jan 2005; Lim Swee Tat
Removed the --enable-daemon line
12 Jan 2005; Lim Swee Tat
Version bump to 3.3.11. May need to support bnr and libdclassify and
nodalcore engine. Removed many unneeded files from files directory.
*dspam-3.2.3 (05 Jan 2005)
05 Jan 2005; Lim Swee Tat
-dspam-3.1.2.ebuild, -dspam-3.2.0.ebuild, -dspam-3.2.1.ebuild,
-dspam-3.2.2.ebuild, -dspam-3.2.3.ebuild:
Version bump URL Fixed Removed older versions of dspam because the latest
version 3.2.4 is finally stable.
04 Jan 2005; Lim Swee Tat
There was a bug fix in dspam for 3.2.4. Upgrade!! Upgrade!!
*dspam-3.3.8 (31 Dec 2004)
31 Dec 2004; Lim Swee Tat
Version bumped at last.
03 Dec 2004; Lim Swee Tat
Version bump
28 Nov 2004; Lim Swee Tat
Fixed bug #71802.
Removed --enable-homedir
Using sqlite-2.7.7
Changing the newdoc to dodoc.
newins for sqlite specific files is done with the correct set of insopts
*dspam-3.2.2 (18 Nov 2004)
18 Nov 2004; Lim Swee Tat
Version bump
12 Nov 2004; Lim Swee Tat
dspam-3.2.1.ebuild:
Oops on bug #70388. Reapplying on 3.2.0
11 Nov 2004; Lim Swee Tat
dspam-3.2.1.ebuild:
Fixed bug #70388, #70647, #70755. Also rearranged some of the wording.
11 Nov 2004; Lim Swee Tat
dspam-3.2.1.ebuild:
Fixed bug #70755
11 Nov 2004; Lim Swee Tat
dspam-3.2.1.ebuild:
Removed the mysql41 use flag
09 Nov 2004; Aron Griffis
Add ~alpha and ~ia64
09 Nov 2004; Lim Swee Tat
Fixed the problem in Bug #70388
*dspam-3.2.1 (05 Nov 2004)
05 Nov 2004; Lim Swee Tat
dspam-3.2.1.ebuild:
Fixing bug #68526, removed preferences-extension from sqlite
02 Nov 2004; Lim Swee Tat
-dspam-3.1.1.ebuild, -dspam-3.2_rc3.ebuild:
Version Bump to 3.2.1.
28 Oct 2004; Lim Swee Tat
dspam-3.1.2.ebuild, dspam-3.2.0.ebuild, dspam-3.2_beta1.ebuild,
dspam-3.2_rc3.ebuild:
Removed the text about the corpus. May want to follow spamassassin's
ruledujour for dspam corpus.
27 Oct 2004; Lim Swee Tat
Fixed bug #68526. Noted that preference-extensions only work when using
mysql and not when using db4.
*dspam-3.2.0 (27 Oct 2004)
27 Oct 2004; Lim Swee Tat
Removed the agent, and removed some lines for db4
*dspam-3.2_rc3 (24 Oct 2004)
24 Oct 2004; Lim Swee Tat
dspam-3.1.0.ebuild, dspam-3.1.1.ebuild, dspam-3.1.2.ebuild,
dspam-3.2_beta1.ebuild, dspam-3.2_rc3.ebuild:
Fixed user permissions on the data directory, and provided correct instructions for train.pl
17 Oct 2004; Lim Swee Tat
dspam-3.1.0.ebuild, dspam-3.1.1.ebuild, dspam-3.1.2.ebuild,
dspam-3.2_beta1.ebuild, -dspam-3.2_rc2.ebuild:
Setting up rc3 as preview release 1
Updated to solve bug #65629
not using courier anymore. Using maildrop
Fixed issues with the 3.2 releases that use dspam.conf
Pls test rc3.!!!
Removing rc2 since that failed miserably. :(
09 Oct 2004; Lim Swee Tat
Changed the UntrustedMailerArgs
09 Oct 2004; Lim Swee Tat
Changed the UntrustedMailerArgs
*dspam-3.2_rc2 (09 Oct 2004)
09 Oct 2004; Lim Swee Tat
dspam-3.1.0.ebuild, dspam-3.1.1.ebuild, dspam-3.1.2.ebuild,
dspam-3.2_beta1.ebuild, +dspam-3.2_rc2.ebuild:
Version bump to 3.2 rc2
exim fixed for everything
28 Sep 2004; Andrej Kacian
Fixed herd name in metadata.xml.
*dspam-3.2_beta1 (25 Sep 2004)
25 Sep 2004; Lim Swee Tat
Version bumped, but not using the latest features yet.
*dspam-3.1.2 (07 Sep 2004)
07 Sep 2004; Lim Swee Tat
Version bump to 3.1.2 but without sqlite support
06 Sep 2004; Ciaran McCreesh
dspam-3.1.1.ebuild:
Switch to use epause and ebeep, bug #62950
26 Aug 2004; Lim Swee Tat
Solved bug #61564 with the help of steveb
Now able to offer a choice of speed optimized or space optimized mysql data.
23 Aug 2004; Lim Swee Tat
Fixed bug #61200
*dspam-3.1.1 (22 Aug 2004)
22 Aug 2004; Lim Swee Tat
files/logrotate.dspam, +dspam-3.1.1.ebuild:
We waited some time before fixing bug #57838. My fault.
Thanx to steveb
3.1.1 built without chi-square and robinson due to compilation errors.
31 Jul 2004; Lim Swee Tat
Version bump
*dspam-3.1.0_beta11-r1 31 Jul 2004
31 Jul 2004; <>
# INSERT ENTRY HERE
*dspam-3.1.0_beta20 (29 Jul 2004)
29 Jul 2004; Lim Swee Tat
Fixed bug #57838.
Added dspam-3.1.0.beta.2 as beta20.
Added support for postgres, but lacking the postgres database/user creation
script.
21 Jul 2004; Lim Swee Tat
dspam-3.1.0_beta11.ebuild:
Changed SLOT to "0"
*dspam-3.1.0_beta11 (21 Jul 2004)
21 Jul 2004; Lim Swee Tat
dspam-3.1.0_beta11.ebuild:
Fixed problem with myconf not taking the delivery-agent options seriously
21 Jul 2004; Lim Swee Tat
Added information to use the user dspam
Added exim,maildrop and cyrus specific delivery agent options
30 Jun 2004; Lim Swee Tat
files/crontab.mysql:
Made a mistake on the cron job. Should not have timing values in
/etc/cron.daily
27 Jun 2004; Aron Griffis
QA - fix use invocation
27 Jun 2004; David Holm
Added to ~ppc.
*dspam-3.0.0 (27 Jun 2004)
27 Jun 2004; Lim Swee Tat
+files/README.qmail, +files/crontab.db4, +files/crontab.mysql,
+files/logrotate.dspam, +files/mysql.data, +files/mysql_create_user.sql,
+files/mysql_install_db, +files/mysql_purge_db, +files/trusted.users,
+files/untrusted.mailer_args, +files/upgrade.sql, +dspam-3.0.0.ebuild:
Initial commit. Most of the ebuild was thanks to work done by Mark Renouf
on bug #26744. I just tried harder to be anal about it. :)
Closing bug.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
AUX README.postfix 309 RMD160 34f35ffa4e393ba1791cef2800bc8b4d4f49df5b SHA1 c004a3e7d54dfdd6fae8a654e44d0b9240935739 SHA256 e0928cf2d734e79419c30a4ee829962351ef5a1247ed1d1ddf3b58410e14828b
AUX README.qmail 2317 RMD160 ebdd90be77441540848caf39b6fcde3d332b2b93 SHA1 081b28b6c261644fe3f799e3bbb5aedf59b00b8f SHA256 c70a32eb183401f3d36b8e13c1e298875692b8a9d3f34151ae42b172dd6f064a
AUX dspam.cron-r3 9269 RMD160 8063c0d0b5a7150a4aa9ba98e62795adca154e20 SHA1 6c1657aefc2a2e391a20c19ffc82475f88d39515 SHA256 e6a1a4194818a6ede5065979227b6b092ef2bea26cad6767f41de1a1952c840d
AUX dspam.rc 1025 RMD160 d223977cf390b1e89392462f06b31b0722810fa3 SHA1 6b243ffac8179120ed7ee6f4b24bf01ad3a511f0 SHA256 9726e4b7699ccbb305d5e161baec2010e115731e582f69c3c670ec36bb099d34
AUX logrotate.dspam 166 RMD160 b289f98cdcdda0879884836a2fdb555dfaf0b802 SHA1 c122df67ab5f5d1c26c993f68a20eb566f1706f3 SHA256 43d0e3bee637a36eadf67509798f21399b9b6f6093826299ee2aabd439555cf6
AUX pgsql_createdb.py 4520 RMD160 bcabe6298a0e97c4b3c10c48f98c5d09eb4a063b SHA1 0fe09f67a4f431dd9bf57a3e6c9ef6662f837403 SHA256 dc107ae72a3832b6ebce1066c5e84a0b164bcc01be74bb7dc1ee28c9135e9768
AUX pgsql_purge.py 1236 RMD160 0fcc6154527932ded25397b093d40d113bb44335 SHA1 198add2080c5d229c77c518ff49b372a6f6f2b93 SHA256 3e996ed8ed5fdbdf3a65504ead870c742be7c0d05f4760e3d7d798205b6cdc1b
DIST dspam-3.8.0-patches-20071231.tar.gz 15159 RMD160 7c26a94a52832221954b7cf894c7651b0b0c6258 SHA1 fc3b29894cd5b53beb2b4b7e777d6fce714b2744 SHA256 d56d86bf245c06a1fc175c1e9e75429cc5b0900d2f9a3a346209c707e0f69754
DIST dspam-3.8.0-patches-20080715.tar.gz 15620 RMD160 714eca562026b2db05aedb82296112b51269d041 SHA1 24d99cabdb97cda7b823f52c8c872b3095008de2 SHA256 a6981635bd848333d2f312ed7fc0f65bae70473dd1928433c53151a21975a7f5
DIST dspam-3.8.0.tar.gz 726160 RMD160 e7831e2415e30e819dd9cbc0ba3f269e113e2fb9 SHA1 d1de7ee2134522adaf52f49167accecf1589fa96 SHA256 84a227934a7aee73516bdb82c33ee7b359e955c8cd95a1544a9a13069f79bfc7
DIST dspam_sa_trainer.tar.gz 1230 RMD160 c3d0fca7169d23ecf9d44c850ee255b42d97d818 SHA1 71a002f26a888bdfe47759cf1f780cd6478dacac SHA256 8fb6b1ebe592acf00a028737ef8e174544af166768b987d29048b2319bc5a215
EBUILD dspam-3.8.0-r11.ebuild 19766 RMD160 2dc77fae5dbbe421fde3ee04f8211bd894270b5e SHA1 565eab492c9e4165937b60da724c6bc52f985b1a SHA256 3892f3e7f9a3d1b9f815a10745eaad08fd3b75486cf8cdf674c2d6a93cb7c651
EBUILD dspam-3.8.0-r12.ebuild 19767 RMD160 8410874833de728617828bdd47288b21f8a7e7f4 SHA1 899165772f12144e416bcb377d0ab56934fd25f3 SHA256 ac9af625847d199c151ea92aeb5e3d4f3ec0acfba0f243a02a7225135e91afd8
MISC ChangeLog 20892 RMD160 39d186a45331bfdf8274297ec8c6104005c35ef9 SHA1 0a7974ccec391f2dda4a68c893963a2d4306ac8d SHA256 f54c62b6df3f4a2a0c988604bb2a89a23a6958ebd6b0b5e65f80ad388d46eb34
MISC metadata.xml 335 RMD160 acb18f015dcada8300ffce56be0c4a285ce2a215 SHA1 87ddabb196434e9e9363ba4b5b5596b78aa463f1 SHA256 23816215482cfc089c2e3fe9ae75547c364ad01fbb2a98886ad91d28f5971e17
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
iEYEARECAAYFAkh8PiIACgkQPrHvTlXvhtsXJwCfRRy5RJqhMNT7wavpDE26xyzF
TSAAn0fPe+Dp1tHZ19M18MgJjFHm/mUb
=c9MP
-----END PGP SIGNATURE-----
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/mail-filter/dspam/dspam-3.8.0-r11.ebuild,v 1.8 2008/06/05 16:02:27 bluebird Exp $
WANT_AUTOCONF="latest"
WANT_AUTOMAKE="latest"
inherit eutils autotools multilib
DESCRIPTION="A statistical-algorithmic hybrid anti-spam filter"
HOMEPAGE="http://dspam.nuclearelephant.com/"
SRC_URI="http://dspam.nuclearelephant.com/sources/${P}.tar.gz
mirror://gentoo/${P}-patches-20071231.tar.gz
http://dspam.nuclearelephant.com/sources/extras/dspam_sa_trainer.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha amd64 ~ppc sparc x86"
IUSE="clamav daemon debug ldap mysql postgres sqlite syslog \
large-domain virtual-users user-homedirs"
COMMON_DEPEND="clamav? ( >=app-antivirus/clamav-0.90.2 )
ldap? ( >=net-nds/openldap-2.2 )
mysql? ( virtual/mysql )
sqlite? ( =dev-db/sqlite-3* )"
DEPEND="${COMMON_DEPEND}
postgres? ( >=virtual/postgresql-base-8 )"
RDEPEND="${COMMON_DEPEND}
postgres? ( || ( dev-python/psycopg >=virtual/postgresql-server-8 ) )
sys-process/cronbase
virtual/logger"
# some FHS-like structure
DSPAM_HOMEDIR="/var/spool/dspam"
DSPAM_CONFDIR="/etc/mail/dspam"
DSPAM_LOGDIR="/var/log/dspam"
DSPAM_MODE=2511
pkg_setup() {
# Delete these lines some time after -r6 removal
if has_version "<=mail-filter/dspam-3.8.0-r6" &&
built_with_use "<=mail-filter/dspam-3.8.0-r6" sqlite &&
grep -q "^StorageDriver.*libsqlite_drv.so" "${ROOT}${DSPAM_CONFDIR}"/dspam.conf; then
eerror "Sqlite2 support has been removed. Please upgrade your database to sqlite3"
eerror "and select libsqlite3_drv.so in dspam.conf before proceeding with update."
die "sqlite-2 no longer supported"
fi
local egid euid
# Need a UID and GID >= 1000, for being able to use suexec in apache
for euid in $(seq 1000 5000 ) ; do
[[ -z $(egetent passwd ${euid}) ]] && break
done
for egid in $(seq 1000 5000 ) ; do
[[ -z $(egetent group ${egid}) ]] && break
done
enewgroup dspam ${egid}
enewuser dspam ${euid} -1 "${DSPAM_HOMEDIR}" dspam,mail
}
src_unpack() {
unpack ${A}
cd "${S}"
EPATCH_SUFFIX="patch"
epatch "${WORKDIR}"/patches
AT_M4DIR="${S}/m4"
eautoreconf
}
src_compile() {
local myconf=""
if use mysql || use postgres; then
myconf="${myconf} $(use_enable virtual-users) --enable-preferences-extension"
if use virtual-users; then
myconf="${myconf} --disable-homedir"
use user-homedirs && ewarn "user-homedirs support has been disabled (not compatible with --enable-virtual-users)"
else
myconf="${myconf} $(use_enable user-homedirs homedir)"
fi
else
myconf="${myconf} --disable-virtual-users --disable-preferences-extension \
$(use_enable user-homedirs homedir)"
use virtual-users && ewarn "virtual-users support has been disabled (available only for mysql and postgres storage drivers)"
fi
if ! use syslog; then
myconf="${myconf} --with-logfile=${DSPAM_LOGDIR}/dspam.log"
fi
local STORAGE="hash_drv"
# select storage driver
if use sqlite ; then
STORAGE="${STORAGE},sqlite3_drv"
fi
if use mysql; then
STORAGE="${STORAGE},mysql_drv"
myconf="${myconf} --with-mysql-includes=/usr/include/mysql"
myconf="${myconf} --with-mysql-libraries=/usr/$(get_libdir)/mysql"
fi
if use postgres ; then
STORAGE="${STORAGE},pgsql_drv"
myconf="${myconf} --with-pgsql-includes=/usr/include/postgresql"
myconf="${myconf} --with-pgsql-libraries=/usr/$(get_libdir)"
fi
econf --with-storage-driver=${STORAGE} \
--with-dspam-home="${DSPAM_HOMEDIR}" \
--sysconfdir="${DSPAM_CONFDIR}" \
$(use_enable daemon) \
$(use_enable ldap) \
$(use_enable clamav) \
$(use_enable large-domain large-scale) \
$(use_enable !large-domain domain-scale) \
$(use_enable syslog) \
$(use_enable debug) \
$(use_enable debug bnr-debug) \
$(use_enable debug verbose-debug) \
--enable-long-usernames \
--with-dspam-group=dspam \
--with-dspam-home-group=dspam \
--with-dspam-mode=${DSPAM_MODE} \
--with-logdir="${DSPAM_LOGDIR}" \
${myconf} || die "econf failed"
emake || die "emake failed"
}
src_install () {
diropts -m0770 -o dspam -g dspam
dodir "${DSPAM_CONFDIR}"
insinto "${DSPAM_CONFDIR}"
insopts -m640 -o dspam -g dspam
doins src/dspam.conf
dosym /etc/mail/dspam /etc/dspam
# make install
emake DESTDIR="${D}" install || die "emake install failed"
# necessary for dovecot-dspam
insopts -m644
insinto /usr/include/dspam && doins src/pref.h
diropts -m0755 -o dspam -g dspam
dodir /var/run/dspam
# create logdir (used only when syslog support has been disabled or build with --enable-debug)
if ! use syslog || use debug ; then
diropts -m0770 -o dspam -g dspam
dodir "${DSPAM_LOGDIR}"
diropts -m0755
insinto /etc/logrotate.d
newins "${FILESDIR}/logrotate.dspam" dspam || die "failed to install logrotate.d file"
fi
if use daemon; then
# We use sockets for the daemon instead of tcp port 24
sed -e 's:^#*\(ServerDomainSocketPath[\t ]\{1,\}\).*:\1\"/var/run/dspam/dspam.sock\":gI' \
-e 's:^#*\(ServerPID[\t ]\{1,\}\).*:\1/var/run/dspam/dspam.pid:gI' \
-e 's:^#*\(ClientHost[\t ]\{1,\}\)/.*:\1\"/var/run/dspam/dspam.sock\":gI' \
-i "${D}/${DSPAM_CONFDIR}/dspam.conf"
newinitd "${FILESDIR}/dspam.rc" dspam || die "failed to install init script"
fowners root:dspam /usr/bin/dspamc &&
fperms u=rx,g=xs,o=x /usr/bin/dspamc ||
die "failed to alter dspamc owner:group or mode"
fi
# database related configuration and scripts
local PASSWORD="${RANDOM}${RANDOM}${RANDOM}${RANDOM}" DSPAM_DB_DATA=()
if use sqlite; then
insinto "${DSPAM_CONFDIR}"
newins src/tools.sqlite_drv/purge-3.sql sqlite3_purge.sql || die "failed to install sqlite3_purge.sql script"
fi
if use mysql; then
DSPAM_DB_DATA[0]="/var/run/mysqld/mysqld.sock"
DSPAM_DB_DATA[1]=""
DSPAM_DB_DATA[2]="dspam"
DSPAM_DB_DATA[3]="${PASSWORD}"
DSPAM_DB_DATA[4]="dspam"
DSPAM_DB_DATA[5]="false"
# Activate mysql database configuration
sed -e "s:^#*\(MySQLServer[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[0]}:gI" \
-e "s:^#*\(MySQLPort[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[1]}:gI" \
-e "s:^#*\(MySQLUser[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[2]}:gI" \
-e "s:^#*\(MySQLPass[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[3]}:gI" \
-e "s:^#*\(MySQLDb[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[4]}:gI" \
-e "s:^#*\(MySQLCompress[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[5]}:gI" \
-i "${D}/${DSPAM_CONFDIR}/dspam.conf"
insinto "${DSPAM_CONFDIR}"
newins src/tools.mysql_drv/mysql_objects-space.sql mysql_objects-space.sql &&
newins src/tools.mysql_drv/mysql_objects-speed.sql mysql_objects-speed.sql &&
newins src/tools.mysql_drv/mysql_objects-4.1.sql mysql_objects-4.1.sql &&
newins src/tools.mysql_drv/purge.sql mysql_purge.sql &&
newins src/tools.mysql_drv/purge-4.1.sql mysql_purge-4.1.sql ||
die "failed to install mysql*.sql scripts"
if use virtual-users ; then
newins src/tools.mysql_drv/virtual_users.sql mysql_virtual_users.sql &&
newins src/tools.mysql_drv/virtual_user_aliases.sql mysql_virtual_user_aliases.sql ||
die "failed to install mysql_virtual_user*.sql scripts"
fi
fi
if use postgres ; then
DSPAM_DB_DATA[0]="127.0.0.1"
DSPAM_DB_DATA[1]="5432"
DSPAM_DB_DATA[2]="dspam"
DSPAM_DB_DATA[3]="${PASSWORD}"
DSPAM_DB_DATA[4]="dspam"
# Activate pgsql database configuration
sed -e "s:^#*\(PgSQLServer[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[0]}:gI" \
-e "s:^#*\(PgSQLPort[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[1]}:gI" \
-e "s:^#*\(PgSQLUser[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[2]}:gI" \
-e "s:^#*\(PgSQLPass[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[3]}:gI" \
-e "s:^#*\(PgSQLDb[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[4]}:gI" \
-e "s:^#*\(PgSQLConnectionCache[\t ]*.\):\1:gI" \
-i "${D}/${DSPAM_CONFDIR}"/dspam.conf
insinto "${DSPAM_CONFDIR}"
newins src/tools.pgsql_drv/pgsql_objects.sql pgsql_objects.sql &&
newins src/tools.pgsql_drv/purge.sql pgsql_purge.sql ||
die "failed to install pgsql*.sql scripts"
if use virtual-users ; then
newins src/tools.pgsql_drv/virtual_users.sql pgsql_virtual_users.sql ||
die "failed to install pgsql_virtual_users.sql scripts"
fi
# Install psycopg scripts needed when postgresql is not installed
exeinto "${DSPAM_CONFDIR}"
doexe "${FILESDIR}"/pgsql_{createdb,purge}.py || die "failed to install psycopg scripts"
fi
# Set default storage
local DEFAULT_STORAGE
if use sqlite ; then
DEFAULT_STORAGE=sqlite3
elif use mysql ; then
DEFAULT_STORAGE=mysql
elif use postgres ; then
DEFAULT_STORAGE=pgsql
fi
if [[ -z "${DEFAULT_STORAGE}" ]]; then
# When only one storage driver is compiled, it is linked statically with dspam
# thus you should not set the StorageDriver at all
# Also, hash_drv requires certain tokenizer and PValue (see bug #185718)
sed -e "s:^\(StorageDriver[\t ].*\)$:#\1:" \
-e "s:^Tokenizer .*$:Tokenizer sbph:" \
-e "/^#PValue/d" \
-e "s:^PValue .*$:PValue markov:" \
-i "${D}/${DSPAM_CONFDIR}"/dspam.conf
else
# Set the storage driver and use purge configuration for SQL-based installations
sed -e "s:^\(Purge.*\):###\1:g" \
-e "s:^#\(Purge.*\):\1:g" \
-e "s:^###\(Purge.*\):#\1:g" \
-e "s:^\(StorageDriver[\t ].*\)libhash_drv.so:\1lib${DEFAULT_STORAGE}_drv.so:" \
-i "${D}/${DSPAM_CONFDIR}"/dspam.conf
fi
# installs the notification messages
# -> The documentation is wrong! The files need to be in ./txt
echo "Scanned and tagged as SPAM with DSPAM ${PV} by Your ISP.com">"${T}"/msgtag.spam
echo "Scanned and tagged as non-SPAM with DSPAM ${PV} by Your ISP.com">"${T}"/msgtag.nonspam
insinto "${DSPAM_CONFDIR}"/txt
doins "${S}"/txt/*.txt
doins "${T}"/msgtag.*
# Create the opt-in / opt-out directories
diropts -m0770 -o dspam -g dspam
dodir "${DSPAM_HOMEDIR}"
keepdir "${DSPAM_HOMEDIR}"/opt-in
keepdir "${DSPAM_HOMEDIR}"/opt-out
diropts -m0755
# dspam cron job
exeinto /etc/cron.daily
newexe "${FILESDIR}/dspam.cron-r3" dspam.cron || die "failed to install cron script"
# documentation
dodoc CHANGELOG README* RELEASE.NOTES UPGRADING
docinto doc
dodoc doc/*.txt
docinto gentoo
dodoc "${FILESDIR}"/README.{postfix,qmail}
docinto sa_train
dodoc "${WORKDIR}"/dspam_sa_trainer/*
doman man/dspam*
}
pkg_preinst() {
# Delete these lines some time after -r6 removal
if has_version "<=mail-filter/dspam-3.8.0-r6" ; then
# Remove obsolete *.data files
local f
for f in "${ROOT}${DSPAM_CONFDIR}"/{mysql,pgsql}.data ; do
f=${f/\/\//\/}
if [[ -f "${f}" ]]; then
rm "${f}" &&
elog "Obsolete ${f} has been removed" ||
eerror "Failed to remove ${f}"
fi
done
fi
}
pkg_postinst() {
ewarn "The hash_drv storage backend has the following requirements:"
ewarn " - PValue must be set to 'markov'; Do not use this pvalue with any other storage backend!"
ewarn " - Tokenizer must be either 'sbph' or 'osb'"
ewarn "See markov.txt for more info."
if use mysql || use postgres; then
elog
elog "To setup DSPAM to run out-of-the-box on your system with a MySQL"
elog "or PostgreSQL database, run:"
elog "emerge --config =${PF}"
fi
if use daemon; then
elog
elog "If you want to run DSPAM in the new daemon mode remember"
elog "to make the DSPAM daemon start during boot:"
elog " rc-update add dspam default"
elog
elog "To use the DSPAM daemon mode, the used storage driver must be thread-safe."
fi
elog
elog "See http://dspamwiki.expass.de/Installation for more info"
}
# Edits interactively one or more parameters from "${ROOT}${DSPAM_CONFDIR}/dspam.conf"
# Usage: edit_dspam_params param_name1 [param_name2 ..]
edit_dspam_params() {
local PARAMETER OLD_VALUE VALUE
for PARAMETER in $@ ; do
OLD_VALUE=$(awk "BEGIN { IGNORECASE=1; } \$1==\"${PARAMETER}\" { print \$2; exit; }" "${ROOT}${DSPAM_CONFDIR}/dspam.conf")
[[ $? == 0 ]] || return 1
if [[ "${PARAMETER}" == *"Pass" ]]; then
read -r -p "${PARAMETER} (default ${OLD_VALUE:-none}; enter random for generating a new random password): " VALUE
[[ "${VALUE}" == "random" ]] && VALUE="${RANDOM}${RANDOM}${RANDOM}${RANDOM}"
else
read -r -p "${PARAMETER} (default ${OLD_VALUE:-none}): " VALUE
fi
if [[ -z "${VALUE}" ]] ; then
VALUE=${OLD_VALUE}
else
sed -e "s:^#*${PARAMETER}\([\t ].*\)\?\$:${PARAMETER} ${VALUE}:gI" \
-i "${ROOT}${DSPAM_CONFDIR}/dspam.conf"
[[ $? == 0 ]] || return 2
fi
eval $PARAMETER=\"${VALUE}\"
done
return 0
}
# Selects the storage driver in "${ROOT}${DSPAM_CONFDIR}/dspam.conf"
# usage: set_storage_driver { hash | sqlite3 | mysql | pgsql }
set_storage_driver() {
sed -e "s:^[#\t ]*\(StorageDriver[\t ].*\)lib[a-z1-9]\+_drv.so:\1lib${1}_drv.so:" \
-i "${ROOT}${DSPAM_CONFDIR}"/dspam.conf &&
einfo "Storage driver lib${1}_drv.so has been selected"
}
pkg_config () {
local AVAIL_BACKENDS=( hash )
use sqlite && AVAIL_BACKENDS=( ${AVAIL_BACKENDS[*]} sqlite )
use mysql && AVAIL_BACKENDS=( ${AVAIL_BACKENDS[*]} mysql )
use postgres && AVAIL_BACKENDS=( ${AVAIL_BACKENDS[*]} postgres )
local USE_BACKEND
read -p "Which backend do you want to configure? (available backends are ${AVAIL_BACKENDS[*]}): " USE_BACKEND
if [[ " ${AVAIL_BACKENDS[*]} " != *" ${USE_BACKEND} "* ]]; then
eerror "The '${USE_BACKEND}' backend is not available."
return 1
fi
case "${USE_BACKEND}" in
hash)
einfo "hash driver will automatically create the necessary databases"
set_storage_driver hash
;;
sqlite)
einfo "sqlite driver will automatically create the necessary databases"
set_storage_driver sqlite3
;;
mysql)
local MySQLServer MySQLPort MySQLUser MySQLPass MySQLDb MySQLCompress
edit_dspam_params MySQLServer MySQLPort MySQLUser MySQLPass MySQLDb MySQLCompress || return $?
if [[ -z "${MySQLServer}" || -z "${MySQLUser}" || -z "${MySQLPass}" || -z "${MySQLDb}" ]]; then
eerror "Following parameters are required: MySQLServer MySQLUser MySQLPass MySQLDb"
return 1
fi
local MySQL_DB_Type MySQL_Virtuser_Type
einfo " Please select what kind of database you like to create:"
einfo " [0] Don't create the database, I will do it myself"
einfo " [1] Database will be hosted on a mysql-4.1 server or above"
einfo " [2] Space optimized database on a mysql-4.0 server or below"
einfo " [3] Speed optimized database on a mysql-4.0 server or below"
einfo
while read -n 1 -s -p " Press 0, 1, 2 or 3 on the keyboard to select database " MySQL_DB_Type; do
if [[ "${MySQL_DB_Type}" == "0" ]] ; then
echo
set_storage_driver mysql
return 0
fi
[[ "${MySQL_DB_Type}" == "1" || "${MySQL_DB_Type}" == "2" || "${MySQL_DB_Type}" == "3" ]] && echo && break
done
if use virtual-users ; then
einfo " Please select what kind of virtual_uids table you like to use:"
einfo " [1] Virtual users added automatically (use it if this server is the primary MX)"
einfo " [2] Virtual users added manually (use it if this server is a secondary MX)"
einfo
while read -n 1 -s -p " Press 1 or 2 on the keyboard to select table type " MySQL_Virtuser_Type; do
[[ "${MySQL_Virtuser_Type}" == "1" || "${MySQL_Virtuser_Type}" == "2" ]] && echo && break
done
fi
local MYSQL_ROOT_USER
read -r -p "Your administrative MySQL account (default root): " MYSQL_ROOT_USER
if [[ -z "${MYSQL_ROOT_USER}" ]]; then
MYSQL_ROOT_USER="root"
fi
einfo "When prompted for a password, please enter your MySQL ${MYSQL_ROOT_USER} password"
local MYSQL_CMD_LINE="/usr/bin/mysql -u ${MYSQL_ROOT_USER} -p"
[[ "${MySQLServer}" != "/"* ]] && MYSQL_CMD_LINE="${MYSQL_CMD_LINE} -h ${MySQLServer}"
[[ -n "${MySQLPort}" ]] && MYSQL_CMD_LINE="${MYSQL_CMD_LINE} -P ${MySQLPort}"
{
echo "CREATE DATABASE ${MySQLDb};"
echo "USE ${MySQLDb};"
case ${MySQL_DB_Type} in
1) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_objects-4.1.sql ;;
2) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_objects-space.sql ;;
3) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_objects-speed.sql ;;
esac
if use virtual-users ; then
case ${MySQL_Virtuser_Type} in
1) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_virtual_users.sql ;;
2) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_virtual_user_aliases.sql ;;
esac
fi
echo "GRANT SELECT,INSERT,UPDATE,DELETE ON ${MySQLDb}.* TO '${MySQLUser}'@'%' IDENTIFIED BY '${MySQLPass}';"
echo "FLUSH PRIVILEGES;"
} | ${MYSQL_CMD_LINE}
[[ ${PIPESTATUS[1]} == 0 ]] || return ${PIPESTATUS[1]}
einfo "MySQL database created successfully"
set_storage_driver mysql
;;
postgres)
local PgSQLServer PgSQLPort PgSQLUser PgSQLPass PgSQLDb
edit_dspam_params PgSQLServer PgSQLPort PgSQLUser PgSQLPass PgSQLDb || return $?
if [[ -z "${PgSQLServer}" || -z "${PgSQLUser}" || -z "${PgSQLPass}" || -z "${PgSQLDb}" ]]; then
eerror "Following parameters are required: PgSQLServer PgSQLUser PgSQLPass PgSQLDb"
return 1
fi
local PgSQL_DB_Create
einfo " Do you want PgSQL database be automatically created for you?"
while read -n 1 -s -p " Press y or n " PgSQL_DB_Create; do
if [[ "${PgSQL_DB_Create}" == "n" || "${PgSQL_DB_Create}" == "N" ]] ; then
echo
set_storage_driver pgsql
return 0
fi
[[ "${PgSQL_DB_Create}" == "y" || "${PgSQL_DB_Create}" == "Y" ]] && echo && break
done
local PGSQL_ROOT_USER
read -r -p "Your administrative PgSQL account (default postgres): " PGSQL_ROOT_USER
if [[ -z "${PGSQL_ROOT_USER}" ]]; then
PGSQL_ROOT_USER="postgres"
fi
einfo "When prompted for a password, please enter your PgSQL ${PGSQL_ROOT_USER} password"
if [[ -x /usr/bin/psql ]]; then
# Create database using psql
local PGSQL_CMD_LINE="/usr/bin/psql -h ${PgSQLServer}"
[[ -n "${PgSQLPort}" ]] && PGSQL_CMD_LINE="${PGSQL_CMD_LINE} -p ${PgSQLPort}"
{
echo "\\set ON_ERROR_STOP = on;"
echo "CREATE USER ${PgSQLUser} WITH PASSWORD '${PgSQLPass}' NOCREATEDB NOCREATEUSER;"
echo "CREATE DATABASE ${PgSQLDb};"
echo "GRANT ALL PRIVILEGES ON DATABASE ${PgSQLDb} TO ${PgSQLUser};"
echo "GRANT ALL PRIVILEGES ON SCHEMA public TO ${PgSQLUser};"
echo "UPDATE pg_database SET datdba=(SELECT usesysid FROM pg_shadow WHERE usename='${PgSQLUser}') WHERE datname='${PgSQLDb}';"
echo "\\c ${PgSQLDb};"
echo "CREATE FUNCTION plpgsql_call_handler() RETURNS language_handler AS '\$libdir/plpgsql', 'plpgsql_call_handler' LANGUAGE c;"
echo "CREATE FUNCTION plpgsql_validator(oid) RETURNS void AS '\$libdir/plpgsql', 'plpgsql_validator' LANGUAGE c;"
echo "CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql HANDLER plpgsql_call_handler VALIDATOR plpgsql_validator;"
} | ${PGSQL_CMD_LINE} -d template1 -U ${PGSQL_ROOT_USER}
[[ ${PIPESTATUS[1]} == 0 ]] || return ${PIPESTATUS[1]}
{
echo "\\set ON_ERROR_STOP = on;"
cat "${ROOT}${DSPAM_CONFDIR}"/pgsql_objects.sql
use virtual-users && cat "${ROOT}${DSPAM_CONFDIR}"/pgsql_virtual_users.sql
} | PGUSER="${PgSQLUser}" PGPASSWORD="${PgSQLPass}" ${PGSQL_CMD_LINE} -d "${PgSQLDb}" -U ${PgSQLUser}
[[ ${PIPESTATUS[1]} == 0 ]] || return ${PIPESTATUS[1]}
else
# Create database using psycopg script
if use virtual-users ; then
DSPAM_PgSQLPass="${PgSQLPass}" "${ROOT}${DSPAM_CONFDIR}"/pgsql_createdb.py "${PgSQLServer}" "${PgSQLPort}" "${PGSQL_ROOT_USER}" \
"${PgSQLUser}" "${PgSQLDb}" "${ROOT}${DSPAM_CONFDIR}"/pgsql_objects.sql "${ROOT}${DSPAM_CONFDIR}"/pgsql_virtual_users.sql
else
DSPAM_PgSQLPass="${PgSQLPass}" "${ROOT}${DSPAM_CONFDIR}"/pgsql_createdb.py "${PgSQLServer}" "${PgSQLPort}" "${PGSQL_ROOT_USER}" \
"${PgSQLUser}" "${PgSQLDb}" "${ROOT}${DSPAM_CONFDIR}"/pgsql_objects.sql
fi
[[ $? == 0 ]] || return $?
fi
einfo "PgSQL database created successfully"
set_storage_driver pgsql
;;
esac
}
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/mail-filter/dspam/dspam-3.8.0-r12.ebuild,v 1.1 2008/07/15 06:05:12 mrness Exp $
WANT_AUTOCONF="latest"
WANT_AUTOMAKE="latest"
inherit eutils autotools multilib
DESCRIPTION="A statistical-algorithmic hybrid anti-spam filter"
HOMEPAGE="http://dspam.nuclearelephant.com/"
SRC_URI="http://dspam.nuclearelephant.com/sources/${P}.tar.gz
mirror://gentoo/${P}-patches-20080715.tar.gz
http://dspam.nuclearelephant.com/sources/extras/dspam_sa_trainer.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~ppc ~sparc ~x86"
IUSE="clamav daemon debug ldap mysql postgres sqlite syslog \
large-domain virtual-users user-homedirs"
COMMON_DEPEND="clamav? ( >=app-antivirus/clamav-0.90.2 )
ldap? ( >=net-nds/openldap-2.2 )
mysql? ( virtual/mysql )
sqlite? ( =dev-db/sqlite-3* )"
DEPEND="${COMMON_DEPEND}
postgres? ( >=virtual/postgresql-base-8 )"
RDEPEND="${COMMON_DEPEND}
postgres? ( || ( dev-python/psycopg >=virtual/postgresql-server-8 ) )
sys-process/cronbase
virtual/logger"
# some FHS-like structure
DSPAM_HOMEDIR="/var/spool/dspam"
DSPAM_CONFDIR="/etc/mail/dspam"
DSPAM_LOGDIR="/var/log/dspam"
DSPAM_MODE=2511
pkg_setup() {
# Delete these lines some time after -r6 removal
if has_version "<=mail-filter/dspam-3.8.0-r6" &&
built_with_use "<=mail-filter/dspam-3.8.0-r6" sqlite &&
grep -q "^StorageDriver.*libsqlite_drv.so" "${ROOT}${DSPAM_CONFDIR}"/dspam.conf; then
eerror "Sqlite2 support has been removed. Please upgrade your database to sqlite3"
eerror "and select libsqlite3_drv.so in dspam.conf before proceeding with update."
die "sqlite-2 no longer supported"
fi
local egid euid
# Need a UID and GID >= 1000, for being able to use suexec in apache
for euid in $(seq 1000 5000 ) ; do
[[ -z $(egetent passwd ${euid}) ]] && break
done
for egid in $(seq 1000 5000 ) ; do
[[ -z $(egetent group ${egid}) ]] && break
done
enewgroup dspam ${egid}
enewuser dspam ${euid} -1 "${DSPAM_HOMEDIR}" dspam,mail
}
src_unpack() {
unpack ${A}
cd "${S}"
EPATCH_SUFFIX="patch"
epatch "${WORKDIR}"/patches
AT_M4DIR="${S}/m4"
eautoreconf
}
src_compile() {
local myconf=""
if use mysql || use postgres; then
myconf="${myconf} $(use_enable virtual-users) --enable-preferences-extension"
if use virtual-users; then
myconf="${myconf} --disable-homedir"
use user-homedirs && ewarn "user-homedirs support has been disabled (not compatible with --enable-virtual-users)"
else
myconf="${myconf} $(use_enable user-homedirs homedir)"
fi
else
myconf="${myconf} --disable-virtual-users --disable-preferences-extension \
$(use_enable user-homedirs homedir)"
use virtual-users && ewarn "virtual-users support has been disabled (available only for mysql and postgres storage drivers)"
fi
if ! use syslog; then
myconf="${myconf} --with-logfile=${DSPAM_LOGDIR}/dspam.log"
fi
local STORAGE="hash_drv"
# select storage driver
if use sqlite ; then
STORAGE="${STORAGE},sqlite3_drv"
fi
if use mysql; then
STORAGE="${STORAGE},mysql_drv"
myconf="${myconf} --with-mysql-includes=/usr/include/mysql"
myconf="${myconf} --with-mysql-libraries=/usr/$(get_libdir)/mysql"
fi
if use postgres ; then
STORAGE="${STORAGE},pgsql_drv"
myconf="${myconf} --with-pgsql-includes=/usr/include/postgresql"
myconf="${myconf} --with-pgsql-libraries=/usr/$(get_libdir)"
fi
econf --with-storage-driver=${STORAGE} \
--with-dspam-home="${DSPAM_HOMEDIR}" \
--sysconfdir="${DSPAM_CONFDIR}" \
$(use_enable daemon) \
$(use_enable ldap) \
$(use_enable clamav) \
$(use_enable large-domain large-scale) \
$(use_enable !large-domain domain-scale) \
$(use_enable syslog) \
$(use_enable debug) \
$(use_enable debug bnr-debug) \
$(use_enable debug verbose-debug) \
--enable-long-usernames \
--with-dspam-group=dspam \
--with-dspam-home-group=dspam \
--with-dspam-mode=${DSPAM_MODE} \
--with-logdir="${DSPAM_LOGDIR}" \
${myconf} || die "econf failed"
emake || die "emake failed"
}
src_install () {
diropts -m0770 -o dspam -g dspam
dodir "${DSPAM_CONFDIR}"
insinto "${DSPAM_CONFDIR}"
insopts -m640 -o dspam -g dspam
doins src/dspam.conf
dosym /etc/mail/dspam /etc/dspam
# make install
emake DESTDIR="${D}" install || die "emake install failed"
# necessary for dovecot-dspam
insopts -m644
insinto /usr/include/dspam && doins src/pref.h
diropts -m0755 -o dspam -g dspam
dodir /var/run/dspam
# create logdir (used only when syslog support has been disabled or build with --enable-debug)
if ! use syslog || use debug ; then
diropts -m0770 -o dspam -g dspam
dodir "${DSPAM_LOGDIR}"
diropts -m0755
insinto /etc/logrotate.d
newins "${FILESDIR}/logrotate.dspam" dspam || die "failed to install logrotate.d file"
fi
if use daemon; then
# We use sockets for the daemon instead of tcp port 24
sed -e 's:^#*\(ServerDomainSocketPath[\t ]\{1,\}\).*:\1\"/var/run/dspam/dspam.sock\":gI' \
-e 's:^#*\(ServerPID[\t ]\{1,\}\).*:\1/var/run/dspam/dspam.pid:gI' \
-e 's:^#*\(ClientHost[\t ]\{1,\}\)/.*:\1\"/var/run/dspam/dspam.sock\":gI' \
-i "${D}/${DSPAM_CONFDIR}/dspam.conf"
newinitd "${FILESDIR}/dspam.rc" dspam || die "failed to install init script"
fowners root:dspam /usr/bin/dspamc &&
fperms u=rx,g=xs,o=x /usr/bin/dspamc ||
die "failed to alter dspamc owner:group or mode"
fi
# database related configuration and scripts
local PASSWORD="${RANDOM}${RANDOM}${RANDOM}${RANDOM}" DSPAM_DB_DATA=()
if use sqlite; then
insinto "${DSPAM_CONFDIR}"
newins src/tools.sqlite_drv/purge-3.sql sqlite3_purge.sql || die "failed to install sqlite3_purge.sql script"
fi
if use mysql; then
DSPAM_DB_DATA[0]="/var/run/mysqld/mysqld.sock"
DSPAM_DB_DATA[1]=""
DSPAM_DB_DATA[2]="dspam"
DSPAM_DB_DATA[3]="${PASSWORD}"
DSPAM_DB_DATA[4]="dspam"
DSPAM_DB_DATA[5]="false"
# Activate mysql database configuration
sed -e "s:^#*\(MySQLServer[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[0]}:gI" \
-e "s:^#*\(MySQLPort[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[1]}:gI" \
-e "s:^#*\(MySQLUser[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[2]}:gI" \
-e "s:^#*\(MySQLPass[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[3]}:gI" \
-e "s:^#*\(MySQLDb[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[4]}:gI" \
-e "s:^#*\(MySQLCompress[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[5]}:gI" \
-i "${D}/${DSPAM_CONFDIR}/dspam.conf"
insinto "${DSPAM_CONFDIR}"
newins src/tools.mysql_drv/mysql_objects-space.sql mysql_objects-space.sql &&
newins src/tools.mysql_drv/mysql_objects-speed.sql mysql_objects-speed.sql &&
newins src/tools.mysql_drv/mysql_objects-4.1.sql mysql_objects-4.1.sql &&
newins src/tools.mysql_drv/purge.sql mysql_purge.sql &&
newins src/tools.mysql_drv/purge-4.1.sql mysql_purge-4.1.sql ||
die "failed to install mysql*.sql scripts"
if use virtual-users ; then
newins src/tools.mysql_drv/virtual_users.sql mysql_virtual_users.sql &&
newins src/tools.mysql_drv/virtual_user_aliases.sql mysql_virtual_user_aliases.sql ||
die "failed to install mysql_virtual_user*.sql scripts"
fi
fi
if use postgres ; then
DSPAM_DB_DATA[0]="127.0.0.1"
DSPAM_DB_DATA[1]="5432"
DSPAM_DB_DATA[2]="dspam"
DSPAM_DB_DATA[3]="${PASSWORD}"
DSPAM_DB_DATA[4]="dspam"
# Activate pgsql database configuration
sed -e "s:^#*\(PgSQLServer[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[0]}:gI" \
-e "s:^#*\(PgSQLPort[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[1]}:gI" \
-e "s:^#*\(PgSQLUser[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[2]}:gI" \
-e "s:^#*\(PgSQLPass[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[3]}:gI" \
-e "s:^#*\(PgSQLDb[\t ]\{1,\}\).*:\1${DSPAM_DB_DATA[4]}:gI" \
-e "s:^#*\(PgSQLConnectionCache[\t ]*.\):\1:gI" \
-i "${D}/${DSPAM_CONFDIR}"/dspam.conf
insinto "${DSPAM_CONFDIR}"
newins src/tools.pgsql_drv/pgsql_objects.sql pgsql_objects.sql &&
newins src/tools.pgsql_drv/purge.sql pgsql_purge.sql ||
die "failed to install pgsql*.sql scripts"
if use virtual-users ; then
newins src/tools.pgsql_drv/virtual_users.sql pgsql_virtual_users.sql ||
die "failed to install pgsql_virtual_users.sql scripts"
fi
# Install psycopg scripts needed when postgresql is not installed
exeinto "${DSPAM_CONFDIR}"
doexe "${FILESDIR}"/pgsql_{createdb,purge}.py || die "failed to install psycopg scripts"
fi
# Set default storage
local DEFAULT_STORAGE
if use sqlite ; then
DEFAULT_STORAGE=sqlite3
elif use mysql ; then
DEFAULT_STORAGE=mysql
elif use postgres ; then
DEFAULT_STORAGE=pgsql
fi
if [[ -z "${DEFAULT_STORAGE}" ]]; then
# When only one storage driver is compiled, it is linked statically with dspam
# thus you should not set the StorageDriver at all
# Also, hash_drv requires certain tokenizer and PValue (see bug #185718)
sed -e "s:^\(StorageDriver[\t ].*\)$:#\1:" \
-e "s:^Tokenizer .*$:Tokenizer sbph:" \
-e "/^#PValue/d" \
-e "s:^PValue .*$:PValue markov:" \
-i "${D}/${DSPAM_CONFDIR}"/dspam.conf
else
# Set the storage driver and use purge configuration for SQL-based installations
sed -e "s:^\(Purge.*\):###\1:g" \
-e "s:^#\(Purge.*\):\1:g" \
-e "s:^###\(Purge.*\):#\1:g" \
-e "s:^\(StorageDriver[\t ].*\)libhash_drv.so:\1lib${DEFAULT_STORAGE}_drv.so:" \
-i "${D}/${DSPAM_CONFDIR}"/dspam.conf
fi
# installs the notification messages
# -> The documentation is wrong! The files need to be in ./txt
echo "Scanned and tagged as SPAM with DSPAM ${PV} by Your ISP.com">"${T}"/msgtag.spam
echo "Scanned and tagged as non-SPAM with DSPAM ${PV} by Your ISP.com">"${T}"/msgtag.nonspam
insinto "${DSPAM_CONFDIR}"/txt
doins "${S}"/txt/*.txt
doins "${T}"/msgtag.*
# Create the opt-in / opt-out directories
diropts -m0770 -o dspam -g dspam
dodir "${DSPAM_HOMEDIR}"
keepdir "${DSPAM_HOMEDIR}"/opt-in
keepdir "${DSPAM_HOMEDIR}"/opt-out
diropts -m0755
# dspam cron job
exeinto /etc/cron.daily
newexe "${FILESDIR}/dspam.cron-r3" dspam.cron || die "failed to install cron script"
# documentation
dodoc CHANGELOG README* RELEASE.NOTES UPGRADING
docinto doc
dodoc doc/*.txt
docinto gentoo
dodoc "${FILESDIR}"/README.{postfix,qmail}
docinto sa_train
dodoc "${WORKDIR}"/dspam_sa_trainer/*
doman man/dspam*
}
pkg_preinst() {
# Delete these lines some time after -r6 removal
if has_version "<=mail-filter/dspam-3.8.0-r6" ; then
# Remove obsolete *.data files
local f
for f in "${ROOT}${DSPAM_CONFDIR}"/{mysql,pgsql}.data ; do
f=${f/\/\//\/}
if [[ -f "${f}" ]]; then
rm "${f}" &&
elog "Obsolete ${f} has been removed" ||
eerror "Failed to remove ${f}"
fi
done
fi
}
pkg_postinst() {
ewarn "The hash_drv storage backend has the following requirements:"
ewarn " - PValue must be set to 'markov'; Do not use this pvalue with any other storage backend!"
ewarn " - Tokenizer must be either 'sbph' or 'osb'"
ewarn "See markov.txt for more info."
if use mysql || use postgres; then
elog
elog "To setup DSPAM to run out-of-the-box on your system with a MySQL"
elog "or PostgreSQL database, run:"
elog "emerge --config =${PF}"
fi
if use daemon; then
elog
elog "If you want to run DSPAM in the new daemon mode remember"
elog "to make the DSPAM daemon start during boot:"
elog " rc-update add dspam default"
elog
elog "To use the DSPAM daemon mode, the used storage driver must be thread-safe."
fi
elog
elog "See http://dspamwiki.expass.de/Installation for more info"
}
# Edits interactively one or more parameters from "${ROOT}${DSPAM_CONFDIR}/dspam.conf"
# Usage: edit_dspam_params param_name1 [param_name2 ..]
edit_dspam_params() {
local PARAMETER OLD_VALUE VALUE
for PARAMETER in $@ ; do
OLD_VALUE=$(awk "BEGIN { IGNORECASE=1; } \$1==\"${PARAMETER}\" { print \$2; exit; }" "${ROOT}${DSPAM_CONFDIR}/dspam.conf")
[[ $? == 0 ]] || return 1
if [[ "${PARAMETER}" == *"Pass" ]]; then
read -r -p "${PARAMETER} (default ${OLD_VALUE:-none}; enter random for generating a new random password): " VALUE
[[ "${VALUE}" == "random" ]] && VALUE="${RANDOM}${RANDOM}${RANDOM}${RANDOM}"
else
read -r -p "${PARAMETER} (default ${OLD_VALUE:-none}): " VALUE
fi
if [[ -z "${VALUE}" ]] ; then
VALUE=${OLD_VALUE}
else
sed -e "s:^#*${PARAMETER}\([\t ].*\)\?\$:${PARAMETER} ${VALUE}:gI" \
-i "${ROOT}${DSPAM_CONFDIR}/dspam.conf"
[[ $? == 0 ]] || return 2
fi
eval $PARAMETER=\"${VALUE}\"
done
return 0
}
# Selects the storage driver in "${ROOT}${DSPAM_CONFDIR}/dspam.conf"
# usage: set_storage_driver { hash | sqlite3 | mysql | pgsql }
set_storage_driver() {
sed -e "s:^[#\t ]*\(StorageDriver[\t ].*\)lib[a-z1-9]\+_drv.so:\1lib${1}_drv.so:" \
-i "${ROOT}${DSPAM_CONFDIR}"/dspam.conf &&
einfo "Storage driver lib${1}_drv.so has been selected"
}
pkg_config () {
local AVAIL_BACKENDS=( hash )
use sqlite && AVAIL_BACKENDS=( ${AVAIL_BACKENDS[*]} sqlite )
use mysql && AVAIL_BACKENDS=( ${AVAIL_BACKENDS[*]} mysql )
use postgres && AVAIL_BACKENDS=( ${AVAIL_BACKENDS[*]} postgres )
local USE_BACKEND
read -p "Which backend do you want to configure? (available backends are ${AVAIL_BACKENDS[*]}): " USE_BACKEND
if [[ " ${AVAIL_BACKENDS[*]} " != *" ${USE_BACKEND} "* ]]; then
eerror "The '${USE_BACKEND}' backend is not available."
return 1
fi
case "${USE_BACKEND}" in
hash)
einfo "hash driver will automatically create the necessary databases"
set_storage_driver hash
;;
sqlite)
einfo "sqlite driver will automatically create the necessary databases"
set_storage_driver sqlite3
;;
mysql)
local MySQLServer MySQLPort MySQLUser MySQLPass MySQLDb MySQLCompress
edit_dspam_params MySQLServer MySQLPort MySQLUser MySQLPass MySQLDb MySQLCompress || return $?
if [[ -z "${MySQLServer}" || -z "${MySQLUser}" || -z "${MySQLPass}" || -z "${MySQLDb}" ]]; then
eerror "Following parameters are required: MySQLServer MySQLUser MySQLPass MySQLDb"
return 1
fi
local MySQL_DB_Type MySQL_Virtuser_Type
einfo " Please select what kind of database you like to create:"
einfo " [0] Don't create the database, I will do it myself"
einfo " [1] Database will be hosted on a mysql-4.1 server or above"
einfo " [2] Space optimized database on a mysql-4.0 server or below"
einfo " [3] Speed optimized database on a mysql-4.0 server or below"
einfo
while read -n 1 -s -p " Press 0, 1, 2 or 3 on the keyboard to select database " MySQL_DB_Type; do
if [[ "${MySQL_DB_Type}" == "0" ]] ; then
echo
set_storage_driver mysql
return 0
fi
[[ "${MySQL_DB_Type}" == "1" || "${MySQL_DB_Type}" == "2" || "${MySQL_DB_Type}" == "3" ]] && echo && break
done
if use virtual-users ; then
einfo " Please select what kind of virtual_uids table you like to use:"
einfo " [1] Virtual users added automatically (use it if this server is the primary MX)"
einfo " [2] Virtual users added manually (use it if this server is a secondary MX)"
einfo
while read -n 1 -s -p " Press 1 or 2 on the keyboard to select table type " MySQL_Virtuser_Type; do
[[ "${MySQL_Virtuser_Type}" == "1" || "${MySQL_Virtuser_Type}" == "2" ]] && echo && break
done
fi
local MYSQL_ROOT_USER
read -r -p "Your administrative MySQL account (default root): " MYSQL_ROOT_USER
if [[ -z "${MYSQL_ROOT_USER}" ]]; then
MYSQL_ROOT_USER="root"
fi
einfo "When prompted for a password, please enter your MySQL ${MYSQL_ROOT_USER} password"
local MYSQL_CMD_LINE="/usr/bin/mysql -u ${MYSQL_ROOT_USER} -p"
[[ "${MySQLServer}" != "/"* ]] && MYSQL_CMD_LINE="${MYSQL_CMD_LINE} -h ${MySQLServer}"
[[ -n "${MySQLPort}" ]] && MYSQL_CMD_LINE="${MYSQL_CMD_LINE} -P ${MySQLPort}"
{
echo "CREATE DATABASE ${MySQLDb};"
echo "USE ${MySQLDb};"
case ${MySQL_DB_Type} in
1) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_objects-4.1.sql ;;
2) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_objects-space.sql ;;
3) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_objects-speed.sql ;;
esac
if use virtual-users ; then
case ${MySQL_Virtuser_Type} in
1) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_virtual_users.sql ;;
2) cat "${ROOT}${DSPAM_CONFDIR}"/mysql_virtual_user_aliases.sql ;;
esac
fi
echo "GRANT SELECT,INSERT,UPDATE,DELETE ON ${MySQLDb}.* TO '${MySQLUser}'@'%' IDENTIFIED BY '${MySQLPass}';"
echo "FLUSH PRIVILEGES;"
} | ${MYSQL_CMD_LINE}
[[ ${PIPESTATUS[1]} == 0 ]] || return ${PIPESTATUS[1]}
einfo "MySQL database created successfully"
set_storage_driver mysql
;;
postgres)
local PgSQLServer PgSQLPort PgSQLUser PgSQLPass PgSQLDb
edit_dspam_params PgSQLServer PgSQLPort PgSQLUser PgSQLPass PgSQLDb || return $?
if [[ -z "${PgSQLServer}" || -z "${PgSQLUser}" || -z "${PgSQLPass}" || -z "${PgSQLDb}" ]]; then
eerror "Following parameters are required: PgSQLServer PgSQLUser PgSQLPass PgSQLDb"
return 1
fi
local PgSQL_DB_Create
einfo " Do you want PgSQL database be automatically created for you?"
while read -n 1 -s -p " Press y or n " PgSQL_DB_Create; do
if [[ "${PgSQL_DB_Create}" == "n" || "${PgSQL_DB_Create}" == "N" ]] ; then
echo
set_storage_driver pgsql
return 0
fi
[[ "${PgSQL_DB_Create}" == "y" || "${PgSQL_DB_Create}" == "Y" ]] && echo && break
done
local PGSQL_ROOT_USER
read -r -p "Your administrative PgSQL account (default postgres): " PGSQL_ROOT_USER
if [[ -z "${PGSQL_ROOT_USER}" ]]; then
PGSQL_ROOT_USER="postgres"
fi
einfo "When prompted for a password, please enter your PgSQL ${PGSQL_ROOT_USER} password"
if [[ -x /usr/bin/psql ]]; then
# Create database using psql
local PGSQL_CMD_LINE="/usr/bin/psql -h ${PgSQLServer}"
[[ -n "${PgSQLPort}" ]] && PGSQL_CMD_LINE="${PGSQL_CMD_LINE} -p ${PgSQLPort}"
{
echo "\\set ON_ERROR_STOP = on;"
echo "CREATE USER ${PgSQLUser} WITH PASSWORD '${PgSQLPass}' NOCREATEDB NOCREATEUSER;"
echo "CREATE DATABASE ${PgSQLDb};"
echo "GRANT ALL PRIVILEGES ON DATABASE ${PgSQLDb} TO ${PgSQLUser};"
echo "GRANT ALL PRIVILEGES ON SCHEMA public TO ${PgSQLUser};"
echo "UPDATE pg_database SET datdba=(SELECT usesysid FROM pg_shadow WHERE usename='${PgSQLUser}') WHERE datname='${PgSQLDb}';"
echo "\\c ${PgSQLDb};"
echo "CREATE FUNCTION plpgsql_call_handler() RETURNS language_handler AS '\$libdir/plpgsql', 'plpgsql_call_handler' LANGUAGE c;"
echo "CREATE FUNCTION plpgsql_validator(oid) RETURNS void AS '\$libdir/plpgsql', 'plpgsql_validator' LANGUAGE c;"
echo "CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql HANDLER plpgsql_call_handler VALIDATOR plpgsql_validator;"
} | ${PGSQL_CMD_LINE} -d template1 -U ${PGSQL_ROOT_USER}
[[ ${PIPESTATUS[1]} == 0 ]] || return ${PIPESTATUS[1]}
{
echo "\\set ON_ERROR_STOP = on;"
cat "${ROOT}${DSPAM_CONFDIR}"/pgsql_objects.sql
use virtual-users && cat "${ROOT}${DSPAM_CONFDIR}"/pgsql_virtual_users.sql
} | PGUSER="${PgSQLUser}" PGPASSWORD="${PgSQLPass}" ${PGSQL_CMD_LINE} -d "${PgSQLDb}" -U ${PgSQLUser}
[[ ${PIPESTATUS[1]} == 0 ]] || return ${PIPESTATUS[1]}
else
# Create database using psycopg script
if use virtual-users ; then
DSPAM_PgSQLPass="${PgSQLPass}" "${ROOT}${DSPAM_CONFDIR}"/pgsql_createdb.py "${PgSQLServer}" "${PgSQLPort}" "${PGSQL_ROOT_USER}" \
"${PgSQLUser}" "${PgSQLDb}" "${ROOT}${DSPAM_CONFDIR}"/pgsql_objects.sql "${ROOT}${DSPAM_CONFDIR}"/pgsql_virtual_users.sql
else
DSPAM_PgSQLPass="${PgSQLPass}" "${ROOT}${DSPAM_CONFDIR}"/pgsql_createdb.py "${PgSQLServer}" "${PgSQLPort}" "${PGSQL_ROOT_USER}" \
"${PgSQLUser}" "${PgSQLDb}" "${ROOT}${DSPAM_CONFDIR}"/pgsql_objects.sql
fi
[[ $? == 0 ]] || return $?
fi
einfo "PgSQL database created successfully"
set_storage_driver pgsql
;;
esac
}