Filter for SpamAssassin/Exim

LawsHosting

Verified User
Joined
Sep 13, 2008
Messages
2,426
Location
London UK
NB. I'm not a professional at bash scripting.

I've imported a few users to a reseller, some these users have the SpamAssassin & Exim filter files (/etc/virtual/domain.com/filter & /etc/virtual/domain.com/filter.conf) to the default, empty (or the default file size). So I would like to know is there a way to loop all users belonging to a specific reseller, checking the current filter files sizes, skip if it's nnn bytes, to do these commands:
domain_create_post.sh said:
cp /usr/local/directadmin/scripts/custom/filter.conf.default /etc/virtual/$domain/filter
chown mail:mail /etc/virtual/$domain/filter.conf

cp /usr/local/directadmin/scripts/custom/filter.default /etc/virtual/$domain/filter
chown mail:mail /etc/virtual/$domain/filter
filter.default contains
filter.default said:
if
$h_X-Spam-Level: contains "***************"
then
seen finish
endif

if
$h_X-Spam-Status: contains "Yes,"
then
seen finish
endif
filter.conf.default contains
filter.conf.default said:
high_score=15
high_score_block=yes
where=delete
Which I assume tells Spamassassin & Exim to delete spam rather than inbox it? I'm not sure which filter is for which (SA or Exim) as I can't see any reference to these filter files in exim.conf.

Similar to http://help.directadmin.com/item.php?id=117 but just to a set of users belonging to a reseller.

Hope I've explained clearly.
Thanks.
 
Last edited:
Note:

16. The finish command

The command finish, which has no arguments, causes Exim to stop interpreting the filter file. This is not a significant action unless preceded by “seen”. A filter file containing only “seen finish” is a black hole.

http://www.exim.org/exim-html-current/doc/html/spec_html/filter_ch03.html#SECTfinish

If you want your rules to be global you might want to use this /etc/system_filter.exim

If you want to update filter rules for users of only one reseller then you might want to try this:

Code:
#!/bin/bash

for user in `cat /usr/local/directadmin/data/users/admin/users.list`;
do
    echo "Found user $user";
    for domain in `cat /usr/local/directadmin/data/users/$user/domains.list`;
    do
        echo "+ Found domain $domain";
        filesize=`stat --printf="%s" /etc/virtual/$domain/filter`
        echo "++ Size of /etc/virtual/$domain/filter is $filesize bytes"

        # Change 261 with your number of bytes
        if [ $filesize -eq 261 ];
        then
            # Put here your instructions...
            echo 1;
        fi;
     done;
done


exit;

replace admin with your reseller's name
 
Thanks for that, much appreciated.

What's the difference with filter and filter.conf? Is filter.conf just the way (and used by) DA rewrites the filter file at every change?
 
filter.conf contains only settings for directadmin, so you could see your preferences in directadmin interface.

filter contains instructions for exim
 
Although, it'll fail/error when domains are disabled (_off extension).

Do you want it another way? Or what?

Code:
#!/bin/bash

for user in `cat /usr/local/directadmin/data/users/admin/users.list`;
do
    echo "Found user $user";

    for domain in `cat /usr/local/directadmin/data/users/$user/domains.list`;
    do

        if [ -d "/etc/virtual/$domain/" ];
        then

            echo "+ Found domain $domain";

            filesize=`stat --printf="%s" /etc/virtual/$domain/filter`;

            echo "++ Size of /etc/virtual/$domain/filter is $filesize bytes";

            # Change 261 with your number of bytes
            if [ $filesize -eq 261 ];
            then

                # Put here your instructions...
                echo 1;

            fi;

        fi;

     done;

done;

exit;

A check is added, now if domain is suspended or does not exist in /etc/virtual/ you won't get those errors.
 
Thanks. Sorry, I was just being observant, I didn't take disabled mail into account in my first post, in that I forgot DA appends _off now.
 
That's OK, I just wanted to know what you want to do with suspended domains: ignore/skip them, or update their filter too?
 
Back
Top