Old 24th June 2010, 09:46
warlock warlock is offline
Join Date: Nov 2008
Posts: 93
Thanks: 1
Thanked 6 Times in 4 Posts
Default Maia MailGuard in ISPC3

I have written a little script that will install Maia Mailguard in ISPConfig3

# Set up the basic environment


/usr/bin/apt-get update
/usr/bin/apt-get --yes upgrade
/usr/bin/apt-get --yes install amavisd-new 
/usr/bin/apt-get --yes install spamassassin
/usr/bin/apt-get --yes install openssh-server
/usr/bin/apt-get --yes install unzip
/usr/bin/apt-get --yes install build-essential
/usr/bin/apt-get --yes install lynx
/usr/bin/apt-get --yes install ncftp2
/usr/bin/apt-get --yes install libssl-dev
/usr/bin/apt-get --yes install apt-show-versions
/usr/bin/apt-get --yes install whois
# Set up apache2
/usr/bin/apt-get --yes install apache2
/usr/bin/apt-get --yes install apache2-doc
/usr/bin/apt-get --yes install libapache2-mod-perl2
/usr/bin/apt-get --yes install libapache2-mod-auth-mysql
/usr/bin/apt-get --yes install libapache2-mod-php5
#Set up MySQL
/usr/bin/apt-get --yes install mysql-server
/usr/bin/apt-get --yes install libgd2
/usr/bin/apt-get --yes install php5
/usr/bin/apt-get --yes install php5-cgi
/usr/bin/apt-get --yes install phpmyadmin
/usr/bin/apt-get --yes install php5-imap
/usr/bin/apt-get --yes install php5-ldap
/usr/bin/apt-get --yes install php5-mcrypt
/usr/bin/apt-get --yes install php5-mysql
/usr/bin/apt-get --yes install php5-gd
/usr/bin/apt-get --yes install php-mail-mime
/usr/bin/apt-get --yes install libcrypt-blowfish-perl
/usr/bin/apt-get --yes install libossp-uuid-perl
/usr/bin/apt-get --yes install libio-zlib-perl
/usr/bin/apt-get --yes install libarchive-tar-perl
/usr/bin/apt-get --yes install libarchive-zip-perl
/usr/bin/apt-get --yes install libtemplate-perl
/usr/bin/apt-get --yes install libemail-address-perl
/usr/bin/apt-get --yes install libconvert-tnef-perl
/usr/bin/apt-get --yes install libnet-cidr-lite-perl
/usr/bin/apt-get --yes install libmail-spf-query-perl
/usr/bin/apt-get --yes install libcrypt-cbc-perl
/usr/bin/apt-get --yes install libdbd-pg-perl 
/usr/bin/apt-get --yes install libnet-ldap-perl
/usr/bin/apt-get --yes install libunix-syslog-perl
/usr/bin/apt-get --yes install libnet-dns-perl
/usr/bin/apt-get --yes install libberkeleydb-perl
/usr/bin/apt-get --yes install imagemagick

cd /tmp
if [ -f /var/cache/apt/$GEOG ]
	cp /var/cache/apt/$GEOG /tmp
	/usr/bin/wget http://search.cpan.org/CPAN/authors/id/A/AB/ABIGAIL/$GEOG
	cp $GEOG /var/cache/apt/$GEOG
tar xvzf Geogra*
cd Geogra*
perl Makefile.PL
make install

cd /tmp
if [ -f /var/cache/apt/$IPCOUNTRY ]
	cp /var/cache/apt/$IPCOUNTRY /tmp
	/usr/bin/wget http://search.cpan.org/CPAN/authors/id/N/NW/NWETTERS/$IPCOUNTRY
	cp $IPCOUNTRY /var/cache/apt/$IPCOUNTRY
tar xvzf IP-Cou*
cd IP-Cou*
perl Makefile.PL
make install

cd /tmp
if [ -f /var/cache/apt/$DOMKEYS ]
	cp /var/cache/apt/$DOMKEYS /tmp
	/usr/bin/wget http://search.cpan.org/CPAN/authors/id/A/AN/ANTHONYU/$DOMKEYS
	cp $DOMKEYS /var/cache/apt/$DOMKEYS
tar xvzf Mail-D*
cd Mail-D*
perl Makefile.PL
make install
/usr/bin/apt-get --yes install php-pear
/usr/bin/pear channel-update pear.php.net
/usr/bin/pear install Mail_Mime
/usr/bin/pear install XML_RPC
/usr/bin/pear install DB_Pager
/usr/bin/pear install Auth_SASL
/usr/bin/pear install Net_Socket
/usr/bin/pear install Net_IMAP
/usr/bin/pear install Net_POP3
/usr/bin/pear install Net_SMTP
/usr/bin/pear install Log
/usr/bin/apt-get --yes install clamav
/usr/bin/apt-get --yes install clamav-daemon
/usr/bin/apt-get --yes install clamav-docs
/usr/bin/apt-get --yes install unrar-free
/usr/bin/apt-get --yes install unzoo
/usr/bin/apt-get --yes install amavis
/usr/bin/apt-get --yes install smarty
/bin/ln -s /usr/share/php/smarty /usr/share/php/Smarty
/usr/bin/pear channel-update pear.php.net
/usr/bin/pear install DB
/usr/bin/pear install Pager
/usr/bin/pear install -f Image_Color
/usr/bin/pear install -f Image_Canvas
/usr/bin/pear install -f Numbers_Words
/usr/bin/pear install Numbers_Roman
/usr/bin/pear install -f Image_Graph-0.7.2
cp /var/cache/apt/Pie.php /usr/share/php/Image/Graph/Plot/Pie.php
/usr/bin/apt-get --yes install razor
/usr/bin/apt-get --yes install pyzor
cp /var/cache/apt/phpinfo.php /var/www/
/etc/init.d/apache2 restart
# Download and Install Maia
cd /usr/src
if [ -f /var/cache/apt/$MAIA ]
	cp /var/cache/apt/$MAIA /usr/src
	/usr/bin/wget http://www.maiamailguard.com/files/$MAIA
	cp $MAIA /var/cache/apt/$MAIA
/bin/tar -zxvf $MAIA
cd maia*

/bin/mkdir         /var/amavisd
/bin/mkdir         /var/amavisd/maia
/bin/mkdir         /var/amavisd/db
/bin/mkdir         /var/amavisd/tmp

/bin/mv scripts    /var/amavisd/maia/
/bin/mv templates  /var/amavisd/maia/
/bin/mv php        /var/www/maia
/bin/mv amavisd-maia /usr/sbin

cat amavisd.conf.dist | sed -e 's/yourdomain.tld/'$DN'/' -e 's/host.domain.tld/'$FQDN'/' -e 's/password/'$PASS'/' -e 's/\/amavisd\/clamd.sock/\/run\/clamav\/clamd.ctl/' -e 's/log_level\ =\ 0/log_level\ =\ 3/' -e 's/\$MYHOME\/amavis.log/\/var\/log\/amavis.log/' -e 's/#\$unrar/\$unrar/' > /etc/amavisd.conf
/bin/mv /var/amavisd/maia/templates/digest.tpl /var/amavisd/maia/templates/digest.tpl.bak
/bin/mv /var/cache/apt/digest.tpl /var/amavisd/maia/templates/digest.tpl

cat maia.conf.dist | sed -e 's/password = "passwd"/password = "'$PASS'"/' -e 's/base_url = "http:\/\/example.com\/"/base_url = "http:\/\/www.'$DN'\/maia"/' -e 's/report_options = 1 + 2 + 4 + 8/report_options = 0/' > /etc/maia.conf
cat /var/www/maia/config.php.dist |sed -e 's/passwd/'$PASS'/'  > /var/www/maia/config.php

cat /var/www/maia/admin/configtest.php | sed -e 's/PEAR\/Remote.php/PEAR\/Command\/Remote.php/' > /var/www/maia/admin/configtest.php.bak
mv /var/www/maia/admin/configtest.php.bak /var/www/maia/admin/configtest.php

# Rotate logs
echo 						 >> /etc/logrotate.conf
echo '# amavis'				 >> /etc/logrotate.conf
echo '/var/log/amavis.log {' >> /etc/logrotate.conf
echo '    missingok'		 >> /etc/logrotate.conf
echo '    daily' 			 >> /etc/logrotate.conf
echo '    rotate 7' 		 >> /etc/logrotate.conf
echo '    create' 			 >> /etc/logrotate.conf
echo '    compress'  		 >> /etc/logrotate.conf
echo '    start 0' 			 >> /etc/logrotate.conf
echo '}' 					 >> /etc/logrotate.conf

# Ceating Maia database
cat maia-mysql.sql | sed -e 's/-- PREAMBLE/USE maia;/' > maia-mysqldb.sql

echo 'DROP DATABASE IF EXISTS maia;' > create_maia_db.sql
echo 'CREATE DATABASE maia;' >> create_maia_db.sql
echo 'USE maia;' >> create_maia_db.sql
echo 'GRANT CREATE, DROP, ALTER, SELECT, INSERT, UPDATE, DELETE ON maia.* TO amavis@localhost IDENTIFIED BY '\'$PASS\'';' >> create_maia_db.sql

/usr/bin/mysql -u root -p$MYSQLPASS  < create_maia_db.sql
/usr/bin/mysql -u root -p$MYSQLPASS  < maia-mysqldb.sql

cd /root

/usr/sbin/adduser www-data amavis

/bin/chown -R amavis. /var/amavisd
/bin/chown -R www-data /var/www/maia
/bin/chown root. /usr/sbin/amavisd-maia
/bin/chown amavis.amavis /etc/maia.conf
/bin/chmod 640 /var/amavisd/maia/templates/*.tpl
/bin/chmod 750 /var/amavisd/maia/scripts/*.pl
/bin/chmod 640 /etc/maia.conf 
/bin/chmod 755 /usr/sbin/amavisd-maia
/bin/ln -s /usr/sbin/amavisd-maia /usr/sbin/amavisd
cat /var/www/maia/core.php | sed -e 's/:.\/libs:/:\/usr\/share\/php/' > /root/core.php
mv /root/core.php /var/www/maia/core.php

cd /etc/default

echo '# /etc/default/amavisd' > amavisd
echo '#' >> amavisd
echo '' >> amavisd
echo '# Change to one to enable amavis' >> amavisd
echo 'ENABLED=1' >> amavisd
echo '' >> amavisd
echo '# Where should amavisd write its PID to file? If you use the -u or' >> amavisd
echo '# --username option above, this needs to be writable by that user.' >> amavisd
echo '# Otherwise, the init script will not be able to shut amavisd down.' >> amavisd
echo 'PIDFILE="/var/amavisd/amavisd.pid"' >> amavisd
echo '' >> amavisd
echo '# Set nice level of spamd' >> amavisd
echo '#NICE="--nicelevel 15"' >> amavisd

cd /etc/init.d

cp /var/cache/apt/amavisd_init.d_script.sh amavisd
chmod 755 amavisd
update-rc.d amavisd defaults
update-rc.d -f amavis remove
cd /root

/etc/init.d/apache2 restart
/etc/init.d/amavis stop
/etc/init.d/amavisd start
mv /etc/init.d/amavis /root

# 8) Setting up cron
# *******************************************************************************
echo '0 * * * * /var/amavisd/maia/scripts/process-quarantine.pl --learn &> /dev/null' >> /var/spool/cron/crontabs/root
echo '0 1 * * * /var/amavisd/maia/scripts/expire-quarantine-cache.pl &> /dev/null' >> /var/spool/cron/crontabs/root
echo '0 2 * * 1 /var/amavisd/maia/scripts/send-quarantine-reminders.pl &> /dev/null' >> /var/spool/cron/crontabs/root
echo '*/30 * * * * /var/amavisd/maia/scripts/send-quarantine-digests.pl &> /dev/null' >> /var/spool/cron/crontabs/root
echo '0 0 * * * sa-update && /var/amavisd/maia/scripts/load-sa-rules.pl && /etc/init.d/amavisd restart' >> /var/spool/cron/crontabs/root
echo '0 * * * * /var/amavisd/maia/scripts/stats-snapshot.pl &> /dev/null' >> /var/spool/cron/crontabs/root

# 9) Done !!!!!
# *******************************************************************************
echo 'Check your install -> http://www.'$DN'/maia/admin/configtest.php'
echo 'Setup initial user -> http://www.'$DN'/maia/internal-init.php'
echo 'Setup super user   -> http://www.'$DN'/maia/login.php?super=register'
You will also need to save this as /var/cache/apt/amavisd_init.d_script.sh
#! /bin/sh

# amavis init script
# February 26, 2006
# David Sims

# Based on SpamAssassin script

DESC="Amavis Mail Filter Daemon"

export TMPDIR=/tmp
# Apparently people have trouble if this isn't explicitly set...

# Defaults - don't touch, edit /etc/default/amavisd

test -f /etc/default/amavisd && . /etc/default/amavisd

if [ "$ENABLED" = "0" ]; then
    echo "$DESC: disabled, see /etc/default/amavisd"
    exit 0

test -f $DAEMON || exit 0

set -e

case "$1" in
	echo -n "Starting $DESC: "
	start-stop-daemon --start --pidfile $PIDFILE --name $PNAME \
	    $NICE --oknodo --startas $DAEMON -- $OPTIONS $DOPTIONS
	echo "$NAME."

	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --pidfile /var/amavisd/amavisd.pid
	rm /var/amavisd/amavisd.lock
	echo "$NAME."

	echo -n "Reloading $DESC: "
	start-stop-daemon --stop --pidfile $PIDFILE --signal HUP --name $PNAME
	echo "$NAME."

	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --pidfile /var/amavisd/amavisd.pid
	start-stop-daemon --start --pidfile $PIDFILE --name $PNAME \
	    $NICE --oknodo --startas $DAEMON -- $OPTIONS $DOPTIONS

	echo "$NAME."

	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	exit 1

exit 0
Use at your own risk and I take no responsibility if it breaks your system
Reply With Quote
The Following 2 Users Say Thank You to warlock For This Useful Post:
falko (25th June 2010), till (24th June 2010)
Sponsored Links
Old 6th August 2010, 06:37
Turbanator Turbanator is offline
Senior Member
Join Date: Jun 2008
Posts: 220
Thanks: 23
Thanked 16 Times in 16 Posts

Any gotchas to note on this? I'm running isp3 on deb lenny 64. I'm wondering if a later upgrade will break anything (doubtful)....or even better...any thought of including this into the next release?
Reply With Quote
Old 7th August 2010, 01:11
Turbanator Turbanator is offline
Senior Member
Join Date: Jun 2008
Posts: 220
Thanks: 23
Thanked 16 Times in 16 Posts

DISREGARD that post please.
Reply With Quote
Old 7th August 2010, 01:15
jwarnier jwarnier is offline
Join Date: Jan 2008
Location: Brussels, Belgium
Posts: 34
Thanks: 5
Thanked 0 Times in 0 Posts

Originally Posted by Turbanator View Post
DISREGARD that post please.
May I ask you why?
Reply With Quote
Old 7th August 2010, 01:21
Turbanator Turbanator is offline
Senior Member
Join Date: Jun 2008
Posts: 220
Thanks: 23
Thanked 16 Times in 16 Posts

I noticed there is a plugin for roundcube that seems to do much of the same in giving users some control.
Reply With Quote
The Following User Says Thank You to Turbanator For This Useful Post:
jwarnier (7th August 2010)
Old 7th August 2010, 13:40
Horfic Horfic is offline
Senior Member
Join Date: Mar 2009
Location: Austria
Posts: 325
Thanks: 55
Thanked 95 Times in 60 Posts
Send a message via Skype™ to Horfic

Well, that are probably my plugins, where the new version will be released on Monday.

PS: If there are feature missing, people just have to tell me.
web wack creations - We create your custom web application
Mailuser interface for ISPConfig 3
Reply With Quote
Old 22nd December 2010, 12:15
xabbu xabbu is offline
Junior Member
Join Date: Dec 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Hi warlock,

thanks for that script but am I right that if I installed maia I must do the spamsettings in maia not in ispconfig?

Reply With Quote
Old 23rd December 2010, 06:51
warlock warlock is offline
Join Date: Nov 2008
Posts: 93
Thanks: 1
Thanked 6 Times in 4 Posts


This is correct, but it now also means that the user has more control
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Maia Mailguard with ISPconfig seangee Installation/Configuration 4 24th June 2010 10:08
Newb: Is there an issue between Drupal zen theme and ISPC3? smartin Installation/Configuration 2 27th January 2010 14:19
Maia Mailguard with ISPConfig 2X 3X pebkac Server Operation 0 23rd April 2009 00:16
How should billing work in ISPC3 redray Developers' Forum 2 6th February 2009 21:23
Force ISPC3 to update apache2 vhost files archerjd Developers' Forum 5 19th December 2008 08:18

All times are GMT +2. The time now is 02:41.

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