Migrating amavisd-new away from the Debian etch package.


Absolutely no warranty, use entirely at your own risk. See the disclaimer at http://www200.pair.com/mecham/spam/.

Purpose: You want to migrate away from the Debian etch amavisd-new 2.4.2 package so you can use newer versions of amavisd-new (as supplied by the developer). However, you don't want to have to migrate all your settings from the Debian supplied configuration files into the original amavisd.conf. The answer is to remove the Debian package (but retain your configuration files), then install the original amavisd-new and use a special amavisd.conf that reads in your Debian configuration files. In order to do this you also need to replace or edit the initscript (/etc/init.d/amavis) and create a symlink from /etc/amavisd.conf to /etc/amavis/amavisd.conf. The initscript from the sarge amavisd-new 20030616p10 package works fine. This HOWTO makes the assumption you are not using amavisd-new-milter and have not patched amavisd-new with the courier or qmqpqq patches. Actually, it assumes you are using Postfix as your SMTP server. If this is not the case then you should not proceed unless you are experienced in setting up amavisd-new manually and are aware in advance of what is required of you. This setup also requires sed version 4.1.5 or newer (supplied with etch) - determine version with: "dpkg -l sed". This document also assumes you have not deleted any of the default configuration files in /etc/amavis/conf.d or /usr/share/amavis/conf.d (or added any new ones of your own). If you have, you can perform this operation but you will need to edit the special amavisd.conf I provide to reflect the changes you have made.

Log in as root. Before we remove amavisd-new we make backup copies of our important files. You should only perform this operation once (to avoid overwriting the original backup). When the amavisd-new package is removed, the /var/lib/amavis and /etc/amavis directories should not be removed (and I do not make a backup copy of /var/lib/amavis) but if you have items in /var/lib/amavis that are important to you, you may want to consider making a copy of that directory (and subdirectories) anyway.
mkdir /usr/ambackup
mkdir -p /usr/ambackup/etc/init.d/
cp /etc/init.d/amavis /usr/ambackup/etc/init.d/amavis
cp -r /etc/amavis /usr/ambackup
mkdir /usr/ambackup/etc/cron.daily
cp /etc/cron.daily/amavisd-new /usr/ambackup/etc/cron.daily/amavisd-new
mkdir /usr/ambackup/etc/cron.d
cp /etc/cron.d/amavisd-new /usr/ambackup/etc/cron.d/amavisd-new
mkdir -p /usr/ambackup/usr/sbin
cp /usr/sbin/amavisd-new-cronjob /usr/ambackup/usr/sbin/amavisd-new-cronjob
mkdir -p /usr/ambackup/usr/share/amavis
cp -r /usr/share/amavis/conf.d /usr/ambackup/usr/share/amavis
cp /usr/sbin/amavisd-new /usr/ambackup/usr/sbin/amavisd-new
mkdir /usr/ambackup/usr/share/perl5
cp /usr/share/perl5/JpegTester.pm /usr/ambackup/usr/share/perl5/JpegTester.pm


Of the files above, JpegTester.pm, /usr/sbin/amavisd-new and /usr/share/amavis/conf.d/ should get deleted when amavisd-new is removed. We will need to restore those from the backups. There may be other files elsewhere that get deleted but they do not affect how amavisd-new functions so their absence will not hurt us. The documentation that we may loose will be provided with the original source code. Test that when you remove amavisd-new, only amavisd-new will be removed:
apt-get -s remove amavisd-new

If it is the only thing that will be removed, continue on:
/etc/init.d/amavis stop
apt-get remove amavisd-new


At this point we are temporarily going to put the same version of amavisd-new back together again so we can continue to process mail. The first command below should all fit on one line:
if ! grep -q amavis /etc/passwd; then adduser --group --system --home /var/lib/amavis --shell /bin/sh amavis; fi

cd /etc/init.d
wget http://www200.pair.com/mecham/debian/amavis-init-20030616
mv amavis-init-20030616 amavis
chmod +x amavis
mkdir -p /usr/share/amavis/conf.d
cp /usr/ambackup/usr/share/amavis/conf.d/* /usr/share/amavis/conf.d
cp /usr/ambackup/usr/sbin/amavisd-new /usr/sbin
cp /usr/ambackup/usr/sbin/amavisd-new /usr/sbin/amavisd-new-debian
cp /usr/ambackup/usr/share/perl5/JpegTester.pm /usr/share/perl5
cp /usr/ambackup/etc/cron.daily/amavisd-new /etc/cron.daily
cp /usr/ambackup/etc/cron.d/amavisd-new /etc/cron.d
cp /usr/ambackup/usr/sbin/amavisd-new-cronjob /usr/sbin
/etc/init.d/amavis start


The Debian amavisd-new package has been removed but you are still using most of the original components of the Debian package. The main difference is the /etc/init.d/amavis init script. Now it should be easy to upgrade to amavisd-new 2.5.2. We will install an amavisd.conf that simply loads in all the Debian conf files:
cd /etc/amavis
test -e amavisd.conf && mv amavisd.conf amavisd.conf-before-migration
wget http://www200.pair.com/mecham/spam/amavisd.conf-etch2.txt
mv amavisd.conf-etch2.txt amavisd.conf
wget http://www200.pair.com/mecham/amavisd/2.5.2/amavisd.conf-modified
wget http://www200.pair.com/mecham/amavisd/2.5.2/amavisd.conf-sample
ln -s /etc/amavis/amavisd.conf /etc/amavisd.conf

cd /usr/local/src
wget http://www.ijs.si/software/amavisd/amavisd-new-2.5.2.tar.gz
tar xzf amavisd-new-2.5.2.tar.gz
cd amavisd-new-2.5.2
cp amavisd /usr/sbin/amavisd-new-2.5.2
cp amavisd /usr/sbin/amavisd-new
cp p0f-analyzer.pl /usr/sbin
test -e /usr/sbin/p0f-analyzer && rm /usr/sbin/p0f-analyzer
ln -s /usr/sbin/p0f-analyzer.pl /usr/sbin/p0f-analyzer
cp amavisd-nanny /usr/sbin/
cp amavisd-release /usr/sbin/
sed -i 's|/var/amavis/amavisd.sock|/var/run/amavis/amavisd.sock|' /usr/sbin/amavisd-release
sed -i 's|/var/amavis/db|/var/lib/amavis/db|' /usr/sbin/amavisd-nanny
amavisd-new reload
cd /etc/amavis
amavisd-new -V


The amavisd.conf-modified file is an example of the amavisd.conf supplied with the source code but it has been modified for use with Debian. I suggest you read /etc/amavis/amavisd.conf.

When the next version of amavisd-new comes along, you might very well be able to simply replace /usr/sbin/amavisd-new with the newer version and reload amavisd-new:

cd /usr/local/src
wget http://www.ijs.si/software/amavisd/amavisd-new-2.5.3.tar.gz
tar xzf amavisd-new-2.5.3.tar.gz
cd amavisd-new-2.5.3
cp amavisd /usr/sbin/amavisd-new-2.5.3
cp amavisd /usr/sbin/amavisd-new
amavisd-new reload



If you are currently using external notification templates (you probably are since they are enabled by default in /etc/amavis/conf.d/30-template_localization), you should get the templates that match amavisd-new 2.5.2 and if necessary modify them in the same manner you have modified the currently installed 2.4.2 templates. The only templates available are English templates. If you don't normally customize your templates you might consider commenting out:
read_l10n_templates('en_US', '/etc/amavis');
in the 30-template_localization file.


cp -r /etc/amavis/en_US /etc/amavis/en_US-backup
cd /etc/amavis/en_US
rm charset
rm template-dsn.txt
rm template-spam-admin.txt
rm template-spam-sender.txt
rm template-virus-admin.txt
rm template-virus-recipient.txt
rm template-virus-sender.txt
wget http://www200.pair.com/mecham/amavisd/2.5.2/en_US/charset
wget http://www200.pair.com/mecham/amavisd/2.5.2/en_US/template-dsn.txt
wget http://www200.pair.com/mecham/amavisd/2.5.2/en_US/template-spam-admin.txt
wget http://www200.pair.com/mecham/amavisd/2.5.2/en_US/template-spam-sender.txt
wget http://www200.pair.com/mecham/amavisd/2.5.2/en_US/template-virus-admin.txt
wget http://www200.pair.com/mecham/amavisd/2.5.2/en_US/template-virus-recipient.txt
wget http://www200.pair.com/mecham/amavisd/2.5.2/en_US/template-virus-sender.txt
amavisd-new reload



If for some crazy reason you should want to reinstall amavisd-new from the Debian package:
apt-get update

/etc/init.d/amavis stop
mv /etc/amavis/amavisd.conf /etc/amavis/amavisd.conf-mybackup
rm /etc/amavisd.conf
apt-get install amavisd-new


If you added configuration items that are only valid for newer versions of amavisd-new then amavisd-new should complain and you will have to remove them before it will start.


mr88talent at yahoo dot com
http://www.freespamfilter.org/forum
22 JUN 07