Monday, September 10, 2007

Quickie script to update mailman aliases

We run sendmail as our MTA and mailman as our list management solution. This is a script that we use to manage updates for mailman aliases. It leverages the built-in mailman command "genaliases" which will regenerate sendmail-style aliases for all of the lists on the system.


#!/bin/bash

#############################################
# local script written to auto-update
# the aliases.mailman file with new list aliases
#
#############################################

/usr/local/mailman/bin/genaliases >/tmp/aliases.mailman
sed -e "1,4d" </tmp/aliases.mailman >/tmp/aliases.mailman2
mv -f /etc/aliases.mailman /etc/aliases.mailman.bak
cp -f /tmp/aliases.mailman2 /etc/aliases.mailman
rm -f /tmp/aliases.mailman*
newaliases


As you can see from the script, all mailman list aliases are stored in the file /etc/aliases.mailman. To make this work, you need a line like this in your /etc/mail/sendmail.mc file:

define(`ALIAS_FILE', `/etc/aliases,/etc/aliases.mailman')dnl

I'm sure there are lots of other ways to do this. I believe that there are contrib scripts for mailman that more tightly integrate it with sendmail. If you're using Postfix, you can take a look at this suggestion.

No comments: