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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s