diff -r 8d180e2a778c -r 29ee99139025 cyrus-migrate.pl --- a/cyrus-migrate.pl Fri Jun 12 15:13:00 2009 +0200 +++ b/cyrus-migrate.pl Tue Jun 16 17:12:11 2009 +0200 @@ -37,6 +37,8 @@ --logdir=s directory where logfiles will go to ($opt_logdir) --maxage=i synchronize only mails younger than $(opt_maxage) --help this help text + --folders only sync folders + --acls fix ACLs # use strict; @@ -62,14 +64,25 @@ my $opt_skip = 0; my $opt_logdir = "./imapsync-log/"; my $opt_maxage = 0; +my $opt_folders = 0; +my $opt_acls = 0; GetOptions( "dry-ryn" => \$opt_dry, "skip" => \$opt_skip, + "folders" => \$opt_folders, + "acls" => \$opt_acls, "logdir=s" => \$opt_logdir, "maxage=i" => \$opt_maxage, ) or die eval "\"$usage\""; +if ($opt_acls) { + system("su - cyrus -c '/usr/sbin/ctl_mboxlist -d' > cyrus_mbox_acls.txt"); + #system('cat cyrus_mbox_acls.txt | sed s/root@[^\t]*/root/ | su - cyrus -c "/usr/sbin/ctl_mboxlist -u"'); + system('cat cyrus_mbox_acls.txt | sed \'s/root@[^\t]*/root/\' | su - cyrus -c "/usr/sbin/ctl_mboxlist -u"'); + + exit 0; +} ### connection to mysql account database my $dbh = DBI->connect($dsn, $db_user, $db_pass, { RaiseError => 1} ) or @@ -107,18 +120,29 @@ $imapsync_options .= " --dry" if $opt_dry; $imapsync_options .= " --maxage=$opt_maxage" if $opt_maxage > 0; - my $logfile = "$opt_logdir/$mailbox.log"; + my $logfile = ">> $opt_logdir/$mailbox.log"; + unlink("opt_logdir/$mailbox.log"); + + my $cmd = < %s", - $imapsync_options, $imap_from_host, $imap_to_host, - $mailbox, $mailbox, $password_of_account_{$mailbox}, - $password_of_account_{$mailbox}, - $logfile); + if ($opt_folders) { + # only INBOX + system("$cmd --syncacls --justfolders --folderrec INBOX $logfile"); + warn "$ME: migration of mailbox $mailbox failed, see $logfile\n" if ($? != 0); - system($cmd); - warn "$ME: migration of mailbox $mailbox failed, see $logfile\n" if ($? != 0); + # now the remaining mailboxes + system("$cmd --syncacls --justfolders $logfile"); + warn "$ME: migration of mailbox $mailbox failed, see $logfile\n" if ($? != 0); + } else { + system("$cmd $logfile"); + warn "$ME: migration of mailbox $mailbox failed, see $logfile\n" if ($? != 0); + } } # vim: sw=4 sts=4 aw