From aca447d83fe78abb65923aa87d73cd8159e7d809 Mon Sep 17 00:00:00 2001 From: Mark Sapiro Date: Sat, 23 Mar 2013 16:39:10 -0700 Subject: A new import_majordomo_into_mailman.pl script has been contributed by Geoff Mayes. LP: #1129742. --- NEWS | 3 + contrib/README.import_majordomo_into_mailman | 60 ++ contrib/import_majordomo_into_mailman.pl | 1417 ++++++++++++++++++++++++++ 3 files changed, 1480 insertions(+) create mode 100644 contrib/README.import_majordomo_into_mailman create mode 100644 contrib/import_majordomo_into_mailman.pl diff --git a/NEWS b/NEWS index 1abf3ada..debb6d50 100755 --- a/NEWS +++ b/NEWS @@ -37,6 +37,9 @@ Here is a history of user visible changes to Mailman. Contributed programs + - A new import_majordomo_into_mailman.pl script has been contributed by + Geoff Mayes. LP: #1129742. + - A new "sitemap" bash script has been contributed by Tomasz Chmielewski to generate a sitemap.xml file of an installation's public archives for submission to search engines. diff --git a/contrib/README.import_majordomo_into_mailman b/contrib/README.import_majordomo_into_mailman new file mode 100644 index 00000000..114da92c --- /dev/null +++ b/contrib/README.import_majordomo_into_mailman @@ -0,0 +1,60 @@ +Import Majordomo into Mailman +============================= + +Create Mailman list(s) from Majordomo list configuration files. + +Features +-------- + +* Import a single list (--list=NAME) +* Import all lists (--all) +* Import subscribers (--subscribers) +* Just generate information about all Majordomo lists (--stats) +* Verbose logging to file +* Control over the console log level (--log-level=[debug|info|notice|warning]) +* Only import lists that have been active within the past N days + + +Requirements +------------ + +* Mailman is installed so that its bin/* scripts can be called. +* Majordomo has all of its list configurations in a single, local directory. +* Majordomo's aliases file exists locally. +* $DOMO_INACTIVITY_LIMIT set to zero or the file path of the output of +Majordomo's consistency_check command. +* Run as root. + + +Before running this script +-------------------------- + +* Change the global variables under "ENVIRONMENT-SPECIFIC VALUES" to match your +system. +* It is recommended to run this script with the --stats option first to get +a sense of your data. Fields with many 'other' or 'no value' values, or +fields that don't get imported (e.g. message_headers) that have many +'has value' values might need to be considered more closely. + + +Testing +------- + +This script was tested against Majordomo 1.94.4/5 and Mailman 2.1.14-1. +Different versions of Majordomo or Mailman may not work with this script. +However, some legacy settings for Majordomo are handled. + + +Limitations +----------- + +* Archives are not currently handled. +* A few Majordomo configuration values are ignored (documented in the comment +above the getMailmanConfig() function) because they are either inactive, +system/constant settings, or don't tranlsate into Mailman. + + +Todo +---- + +* Add an --archives option to also import archives. diff --git a/contrib/import_majordomo_into_mailman.pl b/contrib/import_majordomo_into_mailman.pl new file mode 100644 index 00000000..604546bb --- /dev/null +++ b/contrib/import_majordomo_into_mailman.pl @@ -0,0 +1,1417 @@ +#!/usr/bin/perl + +# +# Create Mailman list(s) from Majordomo list configuration files. +# +# main() is fully commented and provides a good outline of this script. +# +# LIMITATIONS: +# - Archives are not currently handled. +# - A few Majordomo configuration values are ignored (documented in the comment +# above the getMailmanConfig() function) because they are either inactive, +# system/constant settings, or don't tranlsate into Mailman. +# - This script was tested against Majordomo 1.94.4/5 and Mailman 2.1.14-1. +# Different versions of Majordomo or Mailman may not work with this script. +# However, some legacy settings for Majordomo are handled. +# +# REQUIREMENTS/ASSUMPTIONS: +# - Mailman is installed so that its bin/* scripts can be called. +# - Majordomo has all of its list configurations in a single, local directory. +# - Majordomo's aliases file exists locally. +# - $DOMO_INACTIVITY_LIMIT set to zero or the output of Majordomo's +# consistency_check +# command is stored locally. +# - Run this script as root. +# +# BEFORE RUNNING THIS SCRIPT: +# - Change the "ENVIRONMENT-SPECIFIC VALUES" below to match your system. +# - It is recommended to run this script with the --stats option first to get +# a sense of your data. Fields with many 'other' or 'no value' values, or +# fields that don't get imported (e.g. message_headers) that have many +# 'has value' values probably need to be considered more closely. +# +# TODO: IMPORT ARCHIVE OPTION +# - One solution: get all archives inot a 'Unix mbox' file and then use the +# bin/arch tool. bin/cleanarch can sanity check the mbox before running +# bin/arch. +# + +use strict; +use warnings; + +use Getopt::Long; +use Log::Handler; +use File::Temp qw(tempfile); +use Email::Simple; +use Email::Sender::Simple qw(try_to_sendmail); +use Data::Dump qw(dump); + + +#----------------------- ENVIRONMENT-SPECIFIC VALUES --------------------------# +my $DOMO_PATH = '/opt/majordomo'; +my $DOMO_LIST_DIR = "$DOMO_PATH/lists"; +my $MM_PATH = '/usr/local/mailman'; +my $DOMO_ALIASES = "$MM_PATH/majordomo/aliases"; +my $DOMO_CHECK_CONSISTENCY = "$MM_PATH/majordomo/check_consistency.txt"; +my $BOUNCED_OWNERS = "/opt/mailman-2.1.14-1/uo/majordomo/" . + "email_addresses_that_bounced.txt"; +my $TMP_DIR = '/tmp'; +# Only import lists that have been active in the last N days. +my $DOMO_INACTIVITY_LIMIT = 548; # Optional. 548 days = 18 months. +# If set, overwrite Majordomo's "resend_host" and thus Mailman's "host_name". +my $NEW_HOSTNAME = ''; # Optional +my $LANGUAGE = 'en'; # Preferred language for all Mailman lists +my $MAX_MSG_SIZE = 20000; # In KB. Used for the Mailman config. +#------------------------------------------------------------------------------# + +# +# Global constants +# +my $MM_LIST_DIR = "$MM_PATH/lists"; +my $MM_LIST_LISTS = "$MM_PATH/bin/list_lists"; +my $MM_NEWLIST = "$MM_PATH/bin/newlist"; +my $MM_CONFIGLIST = "$MM_PATH/bin/config_list"; +my $MM_ADDMEMBERS = "$MM_PATH/bin/add_members"; +my $MM_CHECK_PERMS = "$MM_PATH/bin/check_perms"; +my $SCRIPT_NAME = $0 =~ /\/?(\b\w+\b)\.pl$/ ? $1 : '