[Mailman-Users] Perl scripts to convert Listproc lists to Mailman

Michael James michael at james.st
Mon Oct 7 19:04:33 CEST 2002


Dear Mailman-users,

Read this part first, it didn't come through the first time.

Our Solaris server got hacked
 and I'm porting its function to an existing Suse Linux box.

Listproc (known with no affection here as "The Impaler")
 won't compile so we have decided to make the break to Mailman.

Washington University announce that they will be porting their maillists
 to Mailman over the next few months.

My situation is a bit different.

I have about 1300 subscribers on 80 lists to re-create in Mailman,
 preferably by tomorrow morning.

Last night I started writing a quick and dirty perl script to do the job,
 seems perfectly possible, I have the lists created already.

There are heaps of similar queries on this list,
 so someone must have written a more complete script
 than I can rush up overnight.

However in case there aren't any out there, here is last nights effort,
 it creates the lists, putting the aliases into /etc/postfix/aliases.lists



#!/usr/local/bin/perl

$LISTPROC       = '/home/alianet/server';
$MAILMAN        = '/usr/lib/mailman';
$ALIASES        = '/etc/postfix/aliases.lists';
$DEFAULT_PW     = 'missing_pw';

$NEWLIST        = "$MAILMAN/bin/newlist";

# Put a header into the new alias file
open(OUT, "> $ALIASES") or die
        "Can't write new aliases file $ALIASES\n";
print OUT "#\tAliases for Mailman Lists\n#\n",
        "#\tWARNING: This file is automatically generated\n",
        "#\tAny changes made here will be lost\n\n";
close(OUT);


# First get a hash of lists and owners.
# Since newlist can only give a list 1 owner
#  we will have to add the other owners later through the web
open(IN, "< $LISTPROC/owners")
        or die "Can't read the Listproc owners file\n";
while (<IN>)
{
        chop;
        s/^\s//;                        # strip leading whitespace
        /^$/ and next;                  # skip blank lines
        /^#/ and next;                  # skip comments

        ($owner, $list, @options) = split;

        $list =~ tr/A-Z/a-z/;           # canonicalize $list
        $list eq 'server' and next;     # dump old Site Manager entry

        unless ( $owners{$list} ) { $owners{$list} = $owner; }
        else    { print "Remember to add $address as an owner to $list\n"; }
}
close(IN);


# Now get the passwords from the config files
opendir(DIR, "$LISTPROC/lists") or
        die "Can't find Listproc Lists directory\n";
foreach $list (readdir(DIR))
{
        -d "$LISTPROC/lists/$list" or next;

        open(IN, "$LISTPROC/lists/$list/config") or do
        {       warn "No config file for $_ list\n";
                next;
        };

        $list =~ tr/A-Z/a-z/;

        while (<IN>)
        {
                chop;
                ($attribute, undef, $value) = split(/\s+/, $_, 3);
                $attribute =~/^passwd$/i and $passwords{$list} = $value;
        }
}
closedir(DIR);


foreach (sort(keys(%owners)))
{
        unless ( $passwords{$_} )
        {       warn "No password for $list list, using $DEFAULT_PW\n";
                $passwords{$_} = $DEFAULT_PW;
        }

        print join ' ', $NEWLIST, '-q', '-o', $ALIASES,
                $_, $owners{$_}, $passwords{$_}, "\n";

        system $NEWLIST, '-q', '-o', $ALIASES,
                $_, $owners{$_}, $passwords{$_};
        print "\n";
}

-- 
A right not exercised is a privilege
a privilege not exercised is illegal.

Michael James			michael at james.st
8 Brennan St			Phone: +61 2 6247 2556
Hackett, ACT 2602		Mobile: +61 4 1747 4065
AUSTRALIA			Fax: +61 2 6278 0011





More information about the Mailman-Users mailing list