Moving Mailman Lists with Linux Server

Updated October 30, 2011 @ 3:40 am

For all the nerds out there, here is a lil script I wrote with some help for being able to rename lists, especially if you are having trouble with aliases generated from your setup. Mailman is simple in using just the folder path names for a list to generate aliases and more. The setup for Fabricatorz is ubuntu latest with mailman and postfix. Have it with the script, and let me know if you make some changes or have problems:

#!/bin/sh
#
# A quick way to rename mailman lists and trust me you aren't going to find
# a better way to do this on ubuntu server
#

OLD="$1"
NEW="$2"

echo $OLD
echo $NEW

/etc/init.d/mailman stop
test -d /var/lib/mailman/archives/private/${NEW} && echo '*** That mailing list name already exists. ***' && exit 1

mv /var/lib/mailman/lists/${OLD} /var/lib/mailman/lists/${NEW}
test -d /var/lib/mailman/archives/private/${OLD} && mv /var/lib/mailman/archives/private/${OLD} /var/lib/mailman/archives/private/${NEW}
mv /var/lib/mailman/archives/private/${OLD}.mbox /var/lib/mailman/archives/private/${NEW}.mbox
test -d /var/lib/mailman/archives/private/${NEW}.mbox/${OLD}.mbox && mv /var/lib/mailman/archives/private/${NEW}.mbox/${OLD}.mbox /var/lib/mailman/archives/private/${NEW}.mbox/${NEW}.mbox && /var/lib/mailman/bin/arch ${NEW} /var/lib/mailman/archives/private/${NEW}.mbox/${NEW}.mbox

newaliases
/var/lib/mailman/bin/genaliases
/etc/init.d/postfix restart
/etc/init.d/mailman start
exit 0

I’m still a nerd.