#!/usr/bin/perl -w
#gpg-ezmlm-convert is a tool to convert a currently existing ezmlm
#list into a gpg-ezmlm list, by replacing the appropriate lines,
#creating the appropriate subdirs, and generating a list key for you.
use Config;
use strict;
my $usage = "Usage: $0
Where is the directory the current ezmlm list lives in, and is in
the form of ~/.qmail-mlname, for a mailing list named mlname. Same as the dot
that you used in ezmlm-make(1). Edit the config file created in the directory
to your preferences.
To convert an existing gpg-ezmlm list to this version, just point the dotfiles
(.qmail- and .qmail--default) to the new gpg-ezmlm-send.pl and
gpg-ezmlm-manage.pl. If you want to change the default configuration settings,
a sample config file has been included, edit to taste.
";
my $installbin = "$Config{installbin}";
my $dir = shift or die $usage;
my $dot = shift or die $usage;
if (!(-d $dir)) {
die "No such directory $dir\n";
}
mkdir "$dir/.gnupg", 0700 or
die "Cannot make $dir/.gnupg: $!\n";
mkdir "$dir/tmp", 0700 or
die "Cannot make $dir/tmp: $!\n";
open NEWDOT, ">$dot.n" or die "Cannot make temporary file $dot.n: $!\n";
open NEWDEFAULT, ">$dot-default.n" or
die "Cannot make temporary file $dot-default.n: $!\n";
open DOT, "<$dot" or die "Cannot open $dot: $!\n";
open DEFAULT, "<$dot-default" or die "Cannot open $dot-default: $!\n";
while () {
my $line = $_;
if ($line =~ /ezmlm-send\s+(\S+)/) {
print NEWDOT "\|$installbin/gpg-ezmlm-send.pl $1\n";
} else {
print NEWDOT $line;
}
}
close (DOT);
close (NEWDOT);
rename "$dot.n", "$dot" or die "Cannot move $dot.n to $dot: $!\n";
while () {
my $line = $_;
if ($line =~ /ezmlm-manage\s+(\S+)/) {
print NEWDEFAULT "\|$installbin/gpg-ezmlm-manage.pl $1\n";
} else {
print NEWDEFAULT $line;
}
}
close (DEFAULT);
close (NEWDEFAULT);
rename "$dot-default.n", "$dot-default"
or die "Cannot move $dot-default.n to $dot-default: $!\n";
open CONFIG, ">$dir/config" or
die "Cannot open $dir/config: $!\n";
print CONFIG <;
if ($input =~ /y/i) {
system("gpg --homedir $dir/.gnupg --gen-key");
} else {
print "OK, skipping key generation for now. Generate later with\n";
print "gpg --homedir $dir/.gnupg --gen-key\n";
exit();
}
open CONFIRM, "<$dir/text/sub-confirm" or
die "Cannot open $dir/text/sub-confirm: $!\n";
open NEWCONFIRM, ">$dir/text/sub-confirm.n" or
die "Cannot open $dir/text/sub-confirm.n: $!\n";
my $line;
while(defined($line = )) {
if($line =~ /an empty reply/) {
$line =~ s/an empty reply/a reply with your\npublic key in the body/;
}
print NEWCONFIRM $line;
}
close(CONFIRM);
print NEWCONFIRM "The public key for this mailing list is contained below:\n";
my $key = `gpg --homedir $dir/.gnupg --export -a`;
print NEWCONFIRM $key;
close(NEWCONFIRM);
rename "$dir/text/sub-confirm.n", "$dir/text/sub-confirm"
or die "Cannot move $dir/text/sub-confirm.n to $dir/text/sub-confirm: $!\n";