Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mailinabox
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mailinabox
Commits
dfe0a9f1
Commit
dfe0a9f1
authored
Oct 12, 2014
by
Joshua Tauberer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up setup/spamassassin.sh
parent
7ca54a2b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
34 deletions
+45
-34
spamassassin.sh
setup/spamassassin.sh
+45
-34
No files found.
setup/spamassassin.sh
View file @
dfe0a9f1
...
@@ -12,6 +12,9 @@
...
@@ -12,6 +12,9 @@
source
/etc/mailinabox.conf
# get global vars
source
/etc/mailinabox.conf
# get global vars
source
setup/functions.sh
# load our functions
source
setup/functions.sh
# load our functions
# Install packages and basic configuration
# ----------------------------------------
# Install packages.
# Install packages.
apt_install spampd razor pyzor dovecot-antispam
apt_install spampd razor pyzor dovecot-antispam
...
@@ -27,23 +30,35 @@ hide_output pyzor discover
...
@@ -27,23 +30,35 @@ hide_output pyzor discover
# We've already configured Dovecot to listen on this port.
# We've already configured Dovecot to listen on this port.
tools/editconf.py /etc/default/spampd
DESTPORT
=
10026
tools/editconf.py /etc/default/spampd
DESTPORT
=
10026
# Enable the Dovecot antispam plugin to detect when a message moves between folders so we can
# Bayesean learning
# pass it to sa-learn for training.
# -----------------
#
# Spamassassin can learn from mail marked as spam or ham, but it needs to be
# configured. We'll store the learning data in our storage area.
#
# These files must be:
#
# * Writable by sa-learn-pipe script below, which run as the 'mail' user, for manual tagging of mail as spam/ham.
# * Readable by the spampd process ('spampd' user) during mail filtering.
# * Writable by the debian-spamd user, which runs /etc/cron.daily/spamassassin.
#
# We'll have these files owned by spampd and grant access to the other two processes.
tools/editconf.py /etc/spamassassin/local.cf
-s
\
bayes_path
=
$STORAGE_ROOT
/mail/spamassassin/bayes
mkdir
-p
$STORAGE_ROOT
/mail/spamassassin
chown
-R
spampd:spampd
$STORAGE_ROOT
/mail/spamassassin
chmod
-R
775
$STORAGE_ROOT
/mail/spamassassin
# To mark mail as spam or ham, just drag it in or out of the Spam folder. We'll
# use the Dovecot antispam plugin to detect the message move operation and execute
# a shell script that invokes learning.
# Enable the Dovecot antispam plugin.
# (Be careful if we use multiple plugins later.) #NODOC
# (Be careful if we use multiple plugins later.) #NODOC
sed
-i
"s/#mail_plugins = .*/mail_plugins =
\$
mail_plugins antispam/"
/etc/dovecot/conf.d/20-imap.conf
sed
-i
"s/#mail_plugins = .*/mail_plugins =
\$
mail_plugins antispam/"
/etc/dovecot/conf.d/20-imap.conf
# When mail is moved in or out of the Dovecot Spam folder, re-train using this script
# that sends the mail to spamassassin.
# from http://wiki2.dovecot.org/Plugins/Antispam
rm
-f
/usr/bin/sa-learn-pipe.sh
# legacy location #NODOC
cat
>
/usr/local/bin/sa-learn-pipe.sh
<<
EOF
;
cat<&0 >> /tmp/sendmail-msg-
\$\$
.txt
/usr/bin/sa-learn
\$
* /tmp/sendmail-msg-
\$\$
.txt > /dev/null
rm -f /tmp/sendmail-msg-
\$\$
.txt
exit 0
EOF
chmod
a+x /usr/local/bin/sa-learn-pipe.sh
# Configure the antispam plugin to call sa-learn-pipe.sh.
# Configure the antispam plugin to call sa-learn-pipe.sh.
cat
>
/etc/dovecot/conf.d/99-local-spampd.conf
<<
EOF
;
cat
>
/etc/dovecot/conf.d/99-local-spampd.conf
<<
EOF
;
plugin {
plugin {
...
@@ -56,30 +71,26 @@ plugin {
...
@@ -56,30 +71,26 @@ plugin {
}
}
EOF
EOF
# Configure site-wide bayesean learning. These files must be:
# Have Dovecot run its mail process with a supplementary group (the spampd group)
#
# so that it can access the learning files.
# * Writable by the sa-learn-pipe script which run as the 'mail' user, for manual tagging of mail as spam/ham.
# * Readable by the spampd process ('spampd' user) during mail filtering.
# * Writable by the debian-spamd user, which runs /etc/cron.daily/spamassassin.
#
# We'll have these files owned by spampd and grant access to the other two processes.
# Create the storage space owned by spampd.
mkdir
-p
$STORAGE_ROOT
/mail/spamassassin
chown
-R
spampd:spampd
$STORAGE_ROOT
/mail/spamassassin
chmod
-R
775
$STORAGE_ROOT
/mail/spamassassin
# Create empty bayes training data (if it doesn't exist) owned by spampd.
sudo
-u
spampd /usr/bin/sa-learn
--sync
2>/dev/null
# Have dovecot execute the antispam script (and other mail processes) in the spampd group
# (as a supplementary group) so that it can read/write these files.
tools/editconf.py /etc/dovecot/conf.d/10-mail.conf
\
tools/editconf.py /etc/dovecot/conf.d/10-mail.conf
\
mail_access_groups
=
spampd
mail_access_groups
=
spampd
# Tell spamassassin where the file is.
# Here's the script that the antispam plugin executes. It spools the message into
tools/editconf.py /etc/spamassassin/local.cf
-s
\
# a temporary file and then runs sa-learn on it.
bayes_path
=
$STORAGE_ROOT
/mail/spamassassin/bayes
# from http://wiki2.dovecot.org/Plugins/Antispam
rm
-f
/usr/bin/sa-learn-pipe.sh
# legacy location #NODOC
cat
>
/usr/local/bin/sa-learn-pipe.sh
<<
EOF
;
cat<&0 >> /tmp/sendmail-msg-
\$\$
.txt
/usr/bin/sa-learn
\$
* /tmp/sendmail-msg-
\$\$
.txt > /dev/null
rm -f /tmp/sendmail-msg-
\$\$
.txt
exit 0
EOF
chmod
a+x /usr/local/bin/sa-learn-pipe.sh
# Create empty bayes training data (if it doesn't exist) owned by spampd.
sudo
-u
spampd /usr/bin/sa-learn
--sync
2>/dev/null
# Initial training?
# Initial training?
# sa-learn --ham storage/mail/mailboxes/*/*/cur/
# sa-learn --ham storage/mail/mailboxes/*/*/cur/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment