patrik
Verified User
- Joined
- Sep 6, 2006
- Messages
- 126
Hi,
I wrote this in another thread but when I noticed the thread was rather old I though I might dedicated a new thread for the scripts.
I have extended the scripts for enabling SpamAssassin by default for new users. I wanted to also be able to add default values for where a spam should be sent (Inbox, spam, user_spam/spambox or deleted).
This is the modified script that goes through every existing user / domain. Note: This will re-set the SpamAssassin configuration for EVERY user. I have called this script enable_spamassassin.sh
This is the slightly modified user_create_post.sh script which is run when a new user has been created. It copies default filter values:
Here's the original http://help.directadmin.com/item.php?id=117
And here is my domain_create_post.sh which is run when a new domain is created and copies default filter values:
The default_filter and default_filter.conf could be created by yourself to suit your needs. An easy way to do this is to enable SpamAssassin on a user and configure it as you want the default values to be. Then go inside /etc/virtual/DOMAIN.TLD/ and copy filter and filter.conf.
Please tell me if you find a bug.
Cheers,
17/10 - 2006: A few changes made in enable_spamassassin.sh
I wrote this in another thread but when I noticed the thread was rather old I though I might dedicated a new thread for the scripts.
I have extended the scripts for enabling SpamAssassin by default for new users. I wanted to also be able to add default values for where a spam should be sent (Inbox, spam, user_spam/spambox or deleted).
This is the modified script that goes through every existing user / domain. Note: This will re-set the SpamAssassin configuration for EVERY user. I have called this script enable_spamassassin.sh
Code:
#!/bin/sh
for i in `ls /usr/local/directadmin/data/users`; do
{
SPAMDIR=/home/$i/.spamassassin
DEFAULTDIR=/usr/local/directadmin/scripts/custom
mkdir -p $SPAMDIR
cp $DEFAULTDIR/default_user_prefs $SPAMDIR/user_prefs
chown ${i}:mail $SPAMDIR
chmod 771 $SPAMDIR
chown $i:$i $SPAMDIR/user_prefs
chmod 755 $SPAMDIR/user_prefs
touch $SPAMDIR/spam
chown mail:$i $SPAMDIR/spam
chmod 660 $SPAMDIR/spam
mkdir -p $SPAMDIR/user_spam
chown ${i}:mail $SPAMDIR/user_spam
chmod 771 $SPAMDIR/user_spam
for j in `cat /usr/local/directadmin/data/users/$i/domains.list`; do
{
cp $DEFAULTDIR/default_filter /etc/virtual/$j/filter
cp $DEFAULTDIR/default_filter.conf /etc/virtual/$j/filter.conf
chown mail:mail /etc/virtual/$j/filter
chown mail:mail /etc/virtual/$j/filter.conf
chmod 640 /etc/virtual/$j/filter
chmod 600 /etc/virtual/$j/filter.conf
# Create every spam box in user_spam
for k in `ls /home/$i/mail/$j`; do
{
touch $SPAMDIR/user_spam/$k@$j
} done;
} done;
};
done;
exit 0;
This is the slightly modified user_create_post.sh script which is run when a new user has been created. It copies default filter values:
Code:
#!/bin/sh
if [ "$spam" = "ON" ]; then
SPAMDIR=/home/$username/.spamassassin
DEFAULTDIR=/usr/local/directadmin/scripts/custom
mkdir $SPAMDIR
cp $DEFAULTDIR/default_user_prefs $DIR/user_prefs
chown ${username}:mail $SPAMDIR
chmod 771 $SPAMDIR
chown $username:$username $SPAMDIR/user_prefs
chmod 755 $SPAMDIR/user_prefs
touch $SPAMDIR/spam
chown mail:$username $SPAMDIR/spam
chmod 660 $SPAMDIR/spam
# Copy the default filter and filter.conf
cp $DEFAULTDIR/default_filter /etc/virtual/$domain/filter
cp $DEFAULTDIR/default_filter.conf /etc/virtual/$domain/filter.conf
chown mail:mail /etc/virtual/$domain/filter
chown mail:mail /etc/virtual/$domain/filter.conf
chmod 640 /etc/virtual/$domain/filter
chmod 600 /etc/virtual/$domain/filter.conf
fi
exit 0;
And here is my domain_create_post.sh which is run when a new domain is created and copies default filter values:
Code:
#!/bin/sh
DEFAULTDIR=/usr/local/directadmin/scripts/custom
# Copy the default filter and filter.conf
cp $DEFAULTDIR/default_filter /etc/virtual/$domain/filter
cp $DEFAULTDIR/default_filter.conf /etc/virtual/$domain/filter.conf
chown mail:mail /etc/virtual/$domain/filter
chown mail:mail /etc/virtual/$domain/filter.conf
chmod 640 /etc/virtual/$domain/filter
chmod 600 /etc/virtual/$domain/filter.conf
exit 0;
The default_filter and default_filter.conf could be created by yourself to suit your needs. An easy way to do this is to enable SpamAssassin on a user and configure it as you want the default values to be. Then go inside /etc/virtual/DOMAIN.TLD/ and copy filter and filter.conf.
Please tell me if you find a bug.
Cheers,
17/10 - 2006: A few changes made in enable_spamassassin.sh
Last edited: