The steps in this posts are for a new install only... See the second post on this thread for upgrade instructions.
The procedure was tested by me on Ensim Pro X.3 for RHEL4. This procedure should also be compatible with any Ensim X. We cannot verify whether this procedure will work on any other platform, however we'd love to hear from anyone whom may have a success story to share.
This HOWTO assumes the reader has a working installation of MailScanner and has an administrator level understanding on how MailScanner works. Please do not proceed with this installation if you don’t meet these requirements and are not comfortable making moderate system modifications.
To perform this installation you need the following.
MYSQL_ROOT_PASSWORD You should already have this
MAILWATCH_ADMIN_PASSWORD You will need to assign one
MAILWATCH_WEB_LOGIN This is the login you will use to access the mailwatch web interface
MAILWATCH_WEB_PASSWORD This is the password for the login above
MAILWATCH_WEB_FULL_NAME This is the full name of the user
Simply replace all instances of the above variables with their actual values in the steps below.
1. Ensure you are running MailScanner 4.43 or later. If you need to upgrade, I have a howto for that here... http://forums.theplanet.com/index.php?showtopic=56002
If you use f-prot, you need the bug fix for the f-prot wrapper over there as well.
2. Log into server as admin
3. Download the mailwatch software.
CODE
wget http://easynews.dl.sourceforge.net/sourceforge/mailwatch/mailwatch-1.0.4.tar.gz
4. Unwind the distribution
tar xfz mailwatch-1.0.4.tar.gz
cd mailwatch-1.0.4
5. Create configuration file for mailwatch php scripts
cp mailscanner/conf.php.example mailscanner/conf.php
vi mailscanner/conf.php
Look for
define(DB_USER, 'root');
define(DB_PASS, '');
and change to
define(DB_USER, 'mailwatch');
define(DB_PASS, 'MAILWATCH_ADMIN_PASSWORD');
Look for
define(QUARANTINE_USE_FLAG, false);
and change to
define(QUARANTINE_USE_FLAG, true);
Fix any other settings you would like to change. I recommened fixing DATE_FORMAT if you are in the US.
6. Update database user/password in MailWatch.pm, SQLBlackWhiteList.pm, and SQLSpamSettings.pm files
vi MailWatch.pm
Look for
my($db_user) = "root";
my($db_pass) = "";
and change it to
my($db_user) = "mailwatch";
my($db_pass) = "MAILWATCH_ADMIN_PASSWORD";
Repeat for SQLBlackWhiteList.pm and SQLSpamSettings.pm
7. Update MailWatch.pm to reduce the messages dumped into maillog and ultimatly mailed out in LogWatch.
vi MailWatch.pm
CODE
Find:
MailScanner::Log::InfoLog("$$message{id}: Logged to MailWatch SQL");
and change to
MailScanner::Log::DebugLog("$$message{id}: Logged to MailWatch SQL");
Find:
MailScanner::Log::InfoLog("Logging message $msg{id} to SQL");
and change to
MailScanner::Log::DebugLog("Logging message $msg{id} to SQL");
MailScanner::Log::InfoLog("$$message{id}: Logged to MailWatch SQL");
and change to
MailScanner::Log::DebugLog("$$message{id}: Logged to MailWatch SQL");
Find:
MailScanner::Log::InfoLog("Logging message $msg{id} to SQL");
and change to
MailScanner::Log::DebugLog("Logging message $msg{id} to SQL");
8. create required temp folder that had gone missing in 1.0.4 tarball
mkdir mailscanner/temp
9. Become root
su
10. Change perms on /var/lib/mysql to actually be allowed to create a database
chmod 775 /var/lib/mysql
11. Create database
/usr/bin/mysql --password=MYSQL_ROOT_PASSWORD < create.sql
12. Change perms on /var/lib/mysql back to ensim locked down configuration
chmod 755 /var/lib/mysql
13. Create mailwatch admin db user
/usr/bin/mysql --password=MYSQL_ROOT_PASSWORD
At the mysql> prompt type:
CODE
GRANT ALL ON mailscanner.* TO mailwatch@localhost IDENTIFIED BY 'MAILWATCH_ADMIN_PASSWORD';
GRANT FILE ON *.* TO mailwatch@localhost IDENTIFIED BY 'MAILWATCH_ADMIN_PASSWORD';
FLUSH PRIVILEGES;
exit
GRANT FILE ON *.* TO mailwatch@localhost IDENTIFIED BY 'MAILWATCH_ADMIN_PASSWORD';
FLUSH PRIVILEGES;
exit
14. Create web login for MailWatch
/usr/bin/mysql mailscanner -u mailwatch --password=MAILWATCH_ADMIN_PASSWORD
At the mysql> prompt type
CODE
INSERT INTO users VALUES ('MAILWATCH_WEB_LOGIN',md5('MAILWATCH_WEB_PASSWORD'),'MAILWATCH_WEB_FULL_NAME','A',0,0,0,0,"");
exit
exit
You should see:
(Query OK, 1 row affected)
15. Move mailwatch files into web root
mv mailscanner /var/www/html
16. set permissions
chown -R root:apache /var/www/html/mailscanner
chmod g+w /var/www/html/mailscanner/images/cache
chmod g+w /var/www/html/mailscanner/temp
17. move MailWatch.pm, SQLBlackWhiteList.pm, and SQLSpamSettings.pm files into place and set ownership
mv MailWatch.pm SQLBlackWhiteList.pm SQLSpamSettings.pm /usr/lib/MailScanner/MailScanner/CustomFunctions
chown root:root /usr/lib/MailScanner/MailScanner/CustomFunctions/MailWatch.pm
chown root:root /usr/lib/MailScanner/MailScanner/CustomFunctions/SQLBlackWhiteList.pm
chown root:root /usr/lib/MailScanner/MailScanner/CustomFunctions/SQLSpamSettings.pm
18. Fix bug in db_clean.php
vi tools/db_clean.php
Find
#!/usr/bin/php -qn
change to
#!/usr/bin/php -q
Find
dbquery("DELETE LOW_PRIORITY FROM maillog WHERE timestamp < (now() - INTERVAL 60 DAY)");
change to:
dbquery("DELETE LOW_PRIORITY FROM maillog WHERE date < (now() - INTERVAL 60 DAY)");
19. Copy mailq.php into place and set permissions
mv mailq.php /usr/local/bin
chown root:root /usr/local/bin/mailq.php
20. Copy other needed scripts into place and set permissions
mv tools/db_clean.php /usr/local/bin
mv tools/quarantine_maint.php /usr/local/bin
mv tools/quarantine_report.php /usr/local/bin
mv tools/sendmail_relay.php /usr/sbin
chown root:root /usr/local/bin/db_clean.php
chown root:root /usr/local/bin/quarantine_maint.php
chown root:root /usr/local/bin/quarantine_report.php
chown root:root /usr/sbin/sendmail_relay.php
21. Set up cron job to run mailq.php
vi /etc/cron.d/mailwatch
copy the following contents into this file
CODE
MAILTO=admin
SHELL=/bin/sh
* * * * * root /usr/local/bin/mailq.php
0 0 * * * root /usr/local/bin/quarantine_maint.php --clean
0 0 * * * root /usr/local/bin/quarantine_report.php
0 0 * * * root /usr/local/bin/db_clean.php
SHELL=/bin/sh
* * * * * root /usr/local/bin/mailq.php
0 0 * * * root /usr/local/bin/quarantine_maint.php --clean
0 0 * * * root /usr/local/bin/quarantine_report.php
0 0 * * * root /usr/local/bin/db_clean.php
22. Check MailScanner settings so that it now logs to MailWatch
vi /etc/MailScanner/MailScanner.conf
Set the following MailScanner variables (if not already)
Always Looked Up Last = &MailWatchLogging
Detailed Spam Report = yes
Include Scores In SpamAssassin Report = yes
Quarantine Whole Message = yes
Quarantine Whole Message As Queue Files = no
Quarantine User = root
Quarantine Group = apache
Quarantine Permissions = 0660
Quarantine Dir = /var/spool/MailScanner/quarantine
Is Definitely Not Spam = &SQLWhitelist
Is Definitely Spam = &SQLBlacklist
Required SpamAssassin Score = &SQLSpamScores
High SpamAssassin Score = &SQLHighSpamScores
You will need to evaluate the settings for the following to determine if these types of messages will be quarantine. (I recommend at least turning on Quarantine Infections, and adding "store" to the High Scoring Spam Actions and High Spam Actions)
Quarantine Infections
Quarantine Silent Viruses
Spam Actions
High Scoring Spam Actions
Non Spam Actions
23. Stop MailScanner
/sbin/service MailScanner stop
24. Consolidate .spamassassin folder so that bayes db is accesible to apache and root users and set perms on it and the shared quarantine folder
mkdir /etc/MailScanner/.spamassassin
mv ~/.spamassassin/* /etc/MailScanner
rmdir ~/.spamassassin
ln -s /etc/MailScanner/.spamassassin ~
ln -s /etc/MailScanner/.spamassassin /var/www
chown root:apache /etc/MailScanner/.spamassassin
chmod g+rwxs /etc/MailScanner/.spamassassin
chown root:apache /var/spool/MailScanner/quarantine
chmod g+rwx /var/spool/MailScanner/quarantine
25. Update MailScanner's spamassassin settings to use new bayes location.
vi /etc/MailScanner/spam.assassin.prefs.conf
Find:
# bayes_file_mode 0770
and change it to
bayes_file_mode 0770
26. Make sure /etc/cron.daily/clean.quarantine is disabled
vi /etc/cron.daily/clean.quarantine
Ensure you have
$disabled = 1;
If not change it.
27. Restart MailScanner
/sbin/service MailScanner start
28. Disable php safe mode for the php scripts that need it.
vi /etc/httpd/conf.d/mailwatch.conf
Add the following lines to the end of the file:
<Directory /var/www/html/mailscanner/>
php_admin_flag safe_mode 0
</Directory>
29. restart httpd
/sbin/service httpd restart
30. Set up sendmail_relay service installed and running.
mv tools/sendmail_relay.init /etc/rc.d/init.d
chown root:root /etc/rc.d/init.d/sendmail_relay.init
ln -s /etc/rc.d/init.d/sendmail_relay.init /etc/rc.d/init.d/mailwatch
/sbin/chkconfig --add mailwatch
31. start sendmail_relay
/sbin/service mailwatch start
32. Fix perms on bayes.mutex
Versions of spamassasin 3.0.x ignore the bayes_file_mode option for the bayes.mutex file which prevents the use of sa-learn functions of mailwatch.
This may be fixed in spamassassin 3.1.x, but I have not tested it. If it is fixed, this step is not needed.
The workaround
chmod 660 /etc/MailScanner/.spamassassin/bayes.mutex
33. Restart spamassassin
/sbin/service spamassassin restart
34. Exit root
exit
35. Cleanup (optional)
cd ..
rm -fr mailwatch
That’s it. MailWatch is now installed. You should now be able to access it as:
http://ip.address/mailscanner
You’ll need to login using the account specified in step 12.
BTW, I strongly recommend you add 127.0.0.1 to the whitelist. You need to if you plan to release messages from the quarrantine and not have your message reblocked. Also you will prevent the accidental blocking of messages that originate on your server.
Good luck.