[Mailman-Users] Converting from Majordomo to mailman

Zeljko Vrba zvrba at iskon.hr
Tue Sep 5 09:51:34 CEST 2000


On Tue, Sep 05, 2000 at 11:42:25AM +0800, Peter Tran wrote:
> Hi,
> 
> Would anyone know of a tool to convert lists and archives from 
> majordomo to mailman?
> 
> Any information would be appricated.
> 
In the attachment is a hack that I wrote for converting Majordomo to Mailman.
You can pipe its output to config_list. You must manually create the list.

-------------- next part --------------
#!/usr/bin/perl -w
use strict;

# UPUTE ZA UPOTREBU
@ARGV or die "usage: $0 LISTNAME\n";

# POTREBNE GLOBALNE VARIJABLE
my $majordomo_list_dir = '/var/lib/majordomo/lists';

my $arg = prepend(shift);

# Ime liste: ovo nam cesto treba
@_ = split /\//, $arg;
my $listname = pop(@_);

# Ovo je lista opcija koje cemo importati iz majordomo listi
my %defaults = (
	real_name => "''",			# ime liste
	owner => "''",				# vlasnik: uzeti iz majoralias
	description => "''",		# opis
	info => "''",				# info
	subject_prefix => "''",		# neka bude ovako
	admin_notify_mchanges => 0,
	administrivia => 1,
	max_message_size => 40,
	host_name => "'iskon.hr'",
	subscribe_policy => 1,
	moderated => 0,
	member_posting_only => 0,
	posters => "[]",
	admin_pwd => "''",
);

sub prepend {
  my ($pth) = @_;
  if ($pth =~ m(/)) {
    return $pth;
  } else {
    return "$majordomo_list_dir/$pth";
  }
}

# POMOCNE PROCEDURE
# Funkcija koja potrazi email vlasnika liste iz majoralias
my $MAJORALIAS = "/etc/mail/majoralias";
sub list_owner {
	my ($name) = @_;
	open(ALIAS, $MAJORALIAS) || die "can't open $MAJORALIAS: $!";
	my ($owner, $host) = ('', '');
	while(<ALIAS>) {
		chomp;
		if (!$owner) {
			if(/^\s*(?:\Q$name\E-owner|owner-\Q$name\E):\s*(\S+)\s*$/o) {
				$owner = $1;
			}
		}
		if (!$host) {
			if (/^\s*\Q$name\E:\s*".*-h\s+(\S+)/o) {
				$host = $1;
			}
		}
		last if $owner && $host;
	}
	close ALIAS;
	return ($owner, $host);
}

# GLAVNI PROGRAM
# Pokupi i pretvori settinge za listu
#if(open(INFO, "$ARGV[0].info")) {
#	while(<INFO>) {
#		$defaults{'info'} .= $_;
#	}
#}
#close INFO;

# Procesiranje glavne konfiguracije
open(DAT, "$arg.config") || die "can't open $arg.config";
$defaults{'real_name'} = "'$listname'";
my ($owner, $host) = list_owner($listname);
$defaults{'owner'} = "'$owner'";
$defaults{'host_name'} = "'$host'" if $host;
while(<DAT>) {
	next if /^\s*#/;
	next unless /^\s*(\S+?)\s*=\s*(\S*)\s*$/;
	local @_ = ($1, $2);
	$_ = $_[0];

	if(/administrivia/) {
		$defaults{'administrivia'} = ($_[1] =~ /no/) ? 0 : 1;
	}
	if(/admin_passwd/) {
		$defaults{'admin_pwd'} = "'$_[1]'";
	}
	if(/moderate/) {
		$defaults{'moderated'} = ($_[1] =~ /no/) ? 0 : 1;
	}
	if(/announcements/) {
		$defaults{'admin_notify_mchanges'} = ($_[1] =~ /no/) ? 0 : 1;
	}
	if(/description/) {
		$_ = <DAT>;
		chomp;
		if(!/^EOF/) {
			$defaults{'description'} = "'" . $_ . "'";
			while(<DAT>) {
				last if /^END/ || /^EOF/;
			}
		}
	}
#	if(/resend_host/ && $_[1] ne '') {
#		$defaults{'host_name'} = "'" . $_[1] . "'";
#	}
	if(/subscribe_policy/) {
		$defaults{'subscribe_policy'} = ($_[1] =~ /closed/) ? 2 : 1;
	}
	if(/restrict_post/ && $_[1] ne '') {
		$_[1] =~ s/^\s*//; $_[1] =~ s/\s*$//;
		if($_[1] eq "") {
			$defaults{'member_posting_only'} = 0;
		} elsif($_[1] eq $listname) {
			$defaults{'member_posting_only'} = 1;
		} elsif(open(RESTRICT, prepend($_[1]))) {
			$defaults{'posters'} = '[';
			while(<RESTRICT>) {
				chomp;
				$defaults{'posters'} .= "'";
				$defaults{'posters'} .= $_;
				$defaults{'posters'} .= "',";
			}
			$defaults{'posters'} .= ']';
			close RESTRICT;
		} else {
			print STDERR "open($_[1]): $!\n";
			print STDERR "can't open restrict list; using member_posting_only=0\n";
		}
	}
}
close DAT;

foreach(keys %defaults) {
	print $_ . "=" . $defaults{$_} . "\n";
}



More information about the Mailman-Users mailing list