Migrate courier and vpopmail to dovecot and vboxadm: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K (x) |
K (x) |
||
Zeile 18: | Zeile 18: | ||
== getuser.pl == | == getuser.pl == | ||
<source lang="perl">#!/usr/bin/perl -w | <source lang="perl"> | ||
#!/usr/bin/perl -w | |||
use strict; | use strict; | ||
#EDIT | |||
my $base = "/var/vpopmail/domains"; | my $base = "/var/vpopmail/domains"; | ||
#rsyc /var/vpopmail/domains to newserver /home/admin/import_mail (extra task!) | |||
my $mailbase = "/home/import_mail"; | |||
my $counter; | my $counter; | ||
my $genalias = ''; | my $genalias = ''; | ||
my $dsync = ''; | |||
foreach my $dir ( <$base/*> ) | foreach my $dir ( <$base/*> ) | ||
{ | { | ||
Zeile 61: | Zeile 68: | ||
} | } | ||
#print "Insert into mailboxes Values (local_part,password,name,is_domainadmin) ('$values[0]','{CRYPT}$values[1]','$values[4]',$is_admin)\n"; | #print "Insert into mailboxes Values (local_part,password,name,is_domainadmin) ('$values[0]','{CRYPT}$values[1]', | ||
print "vboxadm mailbox add $values[0]\@$domain -n '$values[4]' -cp '{CRYPT}$values[1]' --domainadmin $is_admin -a 1\n"; | '$values[4]',$is_admin)\n"; | ||
print "vboxadm mailbox add $values[0]\@$domain -n '$values[4]' -cp '{CRYPT}$values[1]' --domainadmin $is_admin -a | |||
1 -k 50\n"; | |||
$dsync .= "dsync -o mail_location=maildir:$mailbase/$domain/$values[0]/Maildir -u $values[0]\@$domain backup mail | |||
dir:~/Maildir\n"; | |||
$is_admin = 0; | $is_admin = 0; | ||
} | } | ||
Zeile 106: | Zeile 117: | ||
} | } | ||
print $genalias; | print $genalias; | ||
print $dsync; | |||
print "$counter domains\n";</source> | print "$counter domains\n";</source> | ||
[[Category:Mail]] [[Category:Vpopmail]] [[Category:Perl]] | [[Category:Mail]] [[Category:Vpopmail]] [[Category:Perl]] |
Version vom 9. Oktober 2012, 18:27 Uhr
Export User
loop through all domains (e.g. /var/vpopmail/domains)
- open vpasswd to get real mailboxes with crypted (MD5) passwd
- look in all mailboxes for a .qmail to get alias
- look in all .qmail- files to get more aliases
result is a vboxadm-command. vboxadm needs to be patched to import the crypted password
vboxadm mailbox add name@domain.de -n 'my name' -cp '{CRYPT}$1$p0cQI5u5$ldfdfdfdfdfma0wLJ.1' --domainadmin 0 -a 1
vboxadm alias add postmaster@domain 'name@domain.de'
getuser.pl
#!/usr/bin/perl -w
use strict;
#EDIT
my $base = "/var/vpopmail/domains";
#rsyc /var/vpopmail/domains to newserver /home/admin/import_mail (extra task!)
my $mailbase = "/home/import_mail";
my $counter;
my $genalias = '';
my $dsync = '';
foreach my $dir ( <$base/*> )
{
next if (! -d "$dir");
$counter++;
my $domain = $dir;
my $allalias ='';
$domain =~ s/.*\///;
foreach my $file ( <$dir/vpasswd> )
{
next if (!-e $file);
open(IN,'<'.$file) || die "Can not open file $file: $!";
while(<IN>){
next if ($_=~ /^#/);
my @values = split(':',$_);
my $is_admin = 0;
if ( $values[3] == 4096) {$is_admin = 1;}
if ( -e "$dir/$values[0]/.qmail" ){
$allalias ='';
open(INN,'<'."$dir/$values[0]/.qmail") || die "Can not open file $file: $!";
while(<INN>){
next if ($_=~ /^#/);
next if ($_=~ /^\|/);
my $alias = $_;
$alias =~ s/^&//;
chomp($alias);
$allalias = $allalias.";".$alias;
}
close INN;
$allalias =~ s/^;//;
if (length($allalias) >0){
#print "vboxadm alias add $values[0]\@$domain '$allalias'\n";
$genalias .= "vboxadm alias add $values[0]\@$domain '$allalias'\n";
}
}
#print "Insert into mailboxes Values (local_part,password,name,is_domainadmin) ('$values[0]','{CRYPT}$values[1]',
'$values[4]',$is_admin)\n";
print "vboxadm mailbox add $values[0]\@$domain -n '$values[4]' -cp '{CRYPT}$values[1]' --domainadmin $is_admin -a
1 -k 50\n";
$dsync .= "dsync -o mail_location=maildir:$mailbase/$domain/$values[0]/Maildir -u $values[0]\@$domain backup mail
dir:~/Maildir\n";
$is_admin = 0;
}
close IN;
}
#get alias
foreach my $file ( <$dir/.qmail-*> )
{
next if (!-e $file);
next if ($file =~ /.qmail-default/);
my $from = $file;
$from =~ s/.*\///;
$from =~ s/.qmail-//;
# print "$file\n";
$allalias ='';
open(IN,'<'.$file) || die "Can not open file $file: $!";
if ( $from =~ /-owner/) {
#print "++++++++ML++++++++++\n";
#print "Alias $from-help\@$domain \n";
#print "Alias $from-subscribe\@$domain \n";
#print "Alias $from-unsubscribe\@$domain \n";
}
while(<IN>){
next if ( !$_ =~ /^&/);
if ( $_ =~ /^\|/){
next;
print "ACHTUNG $_\n";
}
my $alias = $_;
$alias =~ s/^&//;
chomp($alias);
$allalias = $allalias.";".$alias;
}
close IN;
$allalias =~ s/^;//;
if (length($allalias) >0){
#print "vboxadm alias add $from\@$domain '$allalias'\n";
$genalias .= "vboxadm alias add $from\@$domain '$allalias'\n";
}
}
}
print $genalias;
print $dsync;
print "$counter domains\n";