HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Tips/Tricks/Mods (http://www.howtoforge.com/forums/forumdisplay.php?f=19)
-   -   Using clamd / spamd instead of clamscan / spamassassin in ispconfig 2 (http://www.howtoforge.com/forums/showthread.php?t=46558)

Croydon 15th June 2010 19:55

Using clamd / spamd instead of clamscan / spamassassin in ispconfig 2
 
I know this topic has come up several times here, so I decided to make a little shell script as I needed this myself.

The script below works for debian lenny with ispconfig 2 installed.
I do not guarantee that this will work for you, use it at your own risk

Code:

#!/bin/sh
apt-get -q -y install clamav-daemon spamassassin

/etc/init.d/ispconfig_server stop
/etc/init.d/postfix stop

sed -i -r "s/^CLAMSCAN=.*/CLAMSCAN=\/usr\/bin\/clamdscan/" /home/admispconfig/ispconfig/tools/clamav/bin/clamassassin
sed -i -r "s/^ScanMail .*/ScanMail true/" /etc/clamav/clamd.conf

sed -i -r "s/^NotifyClamd (.*)/#NotifyClamd \1/" /etc/clamav/freshclam.conf
echo "NotifyClamd /etc/clamav/clamd.conf" >> /etc/clamav/freshclam.conf

sed -i -r "s/^NotifyClamd (.*)/#NotifyClamd \1/" /home/admispconfig/ispconfig/tools/clamav/etc/freshclam.conf
echo "NotifyClamd /etc/clamav/clamd.conf" >> /home/admispconfig/ispconfig/tools/clamav/etc/freshclam.conf

sed -i -r "s/^ENABLED=.*/ENABLED=1/" /etc/default/spamassassin
sed -i -r "s/^CRON=.*/CRON=1/" /etc/default/spamassassin

sed -i -r "s/\| .*\-\-prefs\-file.*/\| \/usr\/bin\/spamc/" /root/ispconfig/isp/conf/spamassassin.rc.master
find /var/www/ -name ".spamassassin.rc" -exec sed -i -r "s/\| \/home\/admispc.*\/spamassassin.*/\| \/usr\/bin\/spamc/" {} \;


/etc/init.d/spamassassin restart
/etc/init.d/ispconfig_server restart
/etc/init.d/postfix restart


echo "Update done." ;

What this script does:
- Switches from clamscan bundled with ispc to clamd to reduce server load
- Switches from spamassassin bundled with ispc to spamd/spamc
- Enables daily sa-update cron
- changes all existing user spamassassin config files to use spamc

You should have the debian volatile project in your apt sources.list!

thctlo 5th August 2010 10:20

I would be great if this would be made default in ispconfig2 nexts update.
less compiling, faster updates for debian.

Thank you for the script.

Croydon 6th September 2010 10:51

I just realized a problem with switching to spamd/spamc.

All the SA user config files (like .user_prefs) are created by ispconfig as owner "root".
As spamd/spamc changes the running user to the mailbox owner it is not able to write those config files or tmp/lock files into the .spamassassin directory.
I don't know what further effects this could have (aside from writing lots of permission denied entries to the mail log).

@falko/till: would it be possible to make ispconfig2 change the ownership of those files and the directory to the mailbox owner?
This should not be a problem even if you don't use spamd/spamc.

falko 7th September 2010 16:01

Yes, that should be possible. I've added it to our bugtracker.

Spaetzle 7th October 2010 12:18

As I have some problems with lots of clamscans too I am interested in that to.

If I do the changes proposed by Croydon do I need to redo them after each upgrade of ISPConfig or are those changes untouched by a new Version?

Wouldn't it be a good thing to build in a switch into ispconfig letting anybody choose what to use? clamd and spamd or clamscan and spamassassin.

Best regards
Bernd

falko 8th October 2010 12:40

Quote:

Originally Posted by Spaetzle (Post 241197)
If I do the changes proposed by Croydon do I need to redo them after each upgrade of ISPConfig or are those changes untouched by a new Version?

I think you need to redo them after an upgrade.

Spaetzle 2nd November 2010 17:38

I used this hint now.
It saved my day as my mashines where going down several times having loads of 100% and hundreds of clamscan processes running ...

After changing to clamd/spamd I have not noticed any higher load any more.
So kudos to Croydon.

If there will be an upgrade to ISPconfig I think I only need to do the following steps:
Code:

/etc/init.d/ispconfig_server stop

sed -i -r "s/\| .*\-\-prefs\-file.*/\| \/usr\/bin\/spamc/" /root/ispconfig/isp/conf/spamassassin.rc.master

/etc/init.d/ispconfig_server restart

Or do I need to do more. But I think an ISPCONFIG2 update only touches /root/ispconfig. Or am I wrong with that?

Best regards

Bernd

falko 3rd November 2010 18:01

Quote:

Originally Posted by Spaetzle (Post 243503)
But I think an ISPCONFIG2 update only touches /root/ispconfig.

It also modifies the /home/admispconfig directory.

mini14 10th November 2010 22:49

What would be the procedure to make this swap on a Centos box?

I notice spamassassin taking up quite a bit of processor power at times.

Croydon 21st December 2010 18:44

I had some thoughts about how I could change all the ownerships of the files in the mail user directory with one single command.

So here comes the command - use it at your own risk.
I don't think that it harms anything - but who knows ;)

Code:

find /var/www/ -user root -wholename "*/user/w*" -exec sh -c "(dirname {} | sed -r \"s/.*\/user\/(([^_]+)_[^\/]+)(\/.*)?/chown -v \1:\2 /\" ; echo {}) | xargs echo | xargs -0 sh -c "  \;


All times are GMT +2. The time now is 10:12.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.