Table Of Contents

Previous topic

Requirements

Next topic

Baruwa on Centos/RHEL

This Page

Generic Installation

Install Baruwa

You can install Baruwa either via the Python Package Index (PyPI) or from source.

Install via the Python Package Index (PyPI)

To install using pip:

# pip install baruwa

To install using easy_install:

# easy_install baruwa

Downloading and installing from source

Download the latest version of Baruwa from PyPI

You can install it by doing the following,:

# tar xvfz baruwa-<version>.tar.gz
# cd baruwa-<version>
# python setup.py install

Using the development version

You can clone the repository by doing the following:

# git clone git://github.com/akissa/baruwa.git
# cd baruwa
# python setup.py install

Configure Baruwa

Create the database:

# mysqladmin -u root -p create baruwa

Create a Mysql user for baruwa

Run the command from the mysql prompt:

mysql> GRANT ALL ON baruwa.* TO baruwa@localhost IDENTIFIED BY '<password>';
mysql> flush privileges;

Configure the Baruwa settings

Edit the Baruwa settings.py file:

# baruwa_path=$(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")
# vi $baruwa_path/baruwa/settings.py

Set the following options:

DATABASE_NAME = 'baruwa'
DATABASE_USER = 'baruwa'
DATABASE_PASSWORD = '<password>'
DATABASE_HOST = 'localhost'

Populate the database and create admin user:

# $baruwa_path/baruwa/manage.py syncdb

The syncdb command populates your SQL database and allows you to create the admin user.

Edit the settings.py file and make configuration changes to suit your site.:

# vi $baruwa_path/baruwa/settings.py

Link to the dojo toolkit:

# ln -s /path/to/dojo $baruwa_path/baruwa/static/js
# ln -s /path/to/dojox $baruwa_path/baruwa/static/js
# ln -s /path/to/dijit $baruwa_path/baruwa/static/js

Configure the Web server

Apache/mod_wsgi

Make sure mod_wsgi is enabled, uncomment the following line in /etc/httpd/conf.d/wsgi.conf:

LoadModule wsgi_module modules/mod_wsgi.so

Use the sample configuration provided (extras/baruwa-mod_wsgi.conf) as a template. Copy to your apache configuration directory usually /etc/httpd/conf.d

Make sure that your apache is configured for name based virtual hosting such that you can run other sites on the same box if you wish to.

Edit /etc/httpd/conf.d/baruwa-mod_wsgi.conf and set ServerName to the hostname you will use to access baruwa

Restart apache for the configuration to take effect.:

# /etc/init.d/httpd reload

Lighttpd

Use the generic Lighttpd django instructions.

Nginx

Use the nginx instructions from the nginx wiki

Cherokee

Use the cherokee cookbook instructions.

Configure MailScanner

Edit and install BaruwaSQL.pm

Edit extras/BaruwaSQL.pm and set the variables:

my ($db_name)   = 'baruwa';
my ($db_host)   = 'localhost';
my ($db_user)   = 'baruwa';
my ($db_pass)   = '<password>';
my ($sqlite_db) = "/var/spool/MailScanner/incoming/baruwa.db";

Copy it to the MailScanner custom functions directory:

# confdir=$(/usr/sbin/Quick.Peek 'Custom Functions Dir' /etc/MailScanner/MailScanner.conf)
# cp extras/BaruwaSQL.pm $confdir/

Next edit the MailScanner config file /etc/MailScanner/MailScanner.conf, you need to make sure that the following options are set:

Quarantine User = exim (Or what ever your "Run As User" is set to)
Quarantine Group = apache (or your webserver user if not apache)
Quarantine Permissions = 0660
Quarantine Whole Message = yes
Quarantine Whole Message As Queue Files = no
Detailed Spam Report = yes
Include Scores In SpamAssassin Report = yes
Always Looked Up Last = &BaruwaSQL

To actually quarantine and later process messages with in baruwa, set ‘store’ as one of your keywords for the “Spam Actions” and “High Scoring Spam Actions” MailScanner options

Integrate SQL Blacklists/Whitelists

Edit extras/BaruwaLists.pm and set the variables:

my ($db_name) = 'baruwa';
my ($db_host) = 'localhost';
my ($db_user) = 'baruwa';
my ($db_pass) = '<password>';

Copy it to the MailScanner custom functions directory:

# confdir=$(/usr/sbin/Quick.Peek 'Custom Functions Dir' /etc/MailScanner/MailScanner.conf)
# cp extras/BaruwaLists.pm $confdir/

Next edit the MailScanner config file /etc/MailScanner/MailScanner.conf, and set the following options:

Is Definitely Not Spam = &BaruwaWhitelist
Is Definitely Spam = &BaruwaBlacklist

Integrate per user settings

Edit extras/BaruwaUserSettings.pm and set the variables:

my ($db_name) = 'baruwa';
my ($db_host) = 'localhost';
my ($db_user) = 'baruwa';
my ($db_pass) = '<password>';

Copy it to the MailScanner custom functions directory:

# confdir=$(/usr/sbin/Quick.Peek 'Custom Functions Dir' /etc/MailScanner/MailScanner.conf)
# cp extras/BaruwaUserSettings.pm $confdir

Edit the MailScanner config file /etc/MailScanner/MailScanner.conf, and set the following options:

Required SpamAssassin Score = &BaruwaLowScore
High SpamAssassin Score = &BaruwaHighScore

If you want users to be able to turn off spam checks for their own profiles, set the following options:

Spam Checks = &BaruwaShouldScan

Apply configuration changes

Restart up MailScanner:

# /etc/init.d/MailScanner restart

Testing

Verify that is working

Check your log files you should see

Baruwa SQL logger:

Aug  9 18:58:27 localhost MailScanner[8470]: Logging message 1OiVg7-0003zS-9s to Baruwa SQL
Aug  9 18:58:27 localhost MailScanner[11052]: 1OiVg7-0003zS-9s: Logged to Baruwa SQL

Baruwa Lists:

Aug 9 18:32:42 localhost MailScanner[27260]: Starting Baruwa whitelists
Aug 9 18:32:42 localhost MailScanner[27260]: Read 6 whitelist items
Aug 9 18:32:42 localhost MailScanner[27260]: Ip blocks whitelisted 192.168.1.0/24 192.168.2.0/24 xxx.xx.xxx.0/26

Baruwa User settings:

Aug 9 15:00:03 localhost MailScanner[25708]: Baruwa - Populating spam score settings
Aug 9 15:00:03 localhost MailScanner[25708]: Read 1 spam score settings
Aug 9 14:59:53 localhost MailScanner[25668]: Baruwa - Populating high spam score settings
Aug 9 14:59:53 localhost MailScanner[25668]: Read 1 high spam score settings

Point your browser to http://hostname_used login with admin user and password and start working. You can now use the interface to add users, domains and process messages, etc etc.