cyrus-imapd/folderxfer
John Dennis 38f2261a6f auto-import cyrus-imapd-2.2.12-1.2.fc4 on branch devel from
cyrus-imapd-2.2.12-1.2.fc4.src.rpm
2005-04-15 20:24:15 +00:00

47 lines
1.2 KiB
Perl

#!/usr/bin/perl
#
# Usage: folderxfer inputfile
#
# Purpose: Converts contents of Berkeley-format mail folders
# to Cyrus mailboxes
#
# Input: Output of 'bsd2cyrus'
# (username:Cyrus-folder-name:Berkeley-folder-path)
#
# Warnings: The root mailbox and empty Cyrus folder must
# exist before conversion takes place, and source folders
# should be checked for RFC 822 content before being processed
#
#$Id: folderxfer,v 1.1 2004/02/04 12:59:42 karsten Exp $
$pwd = "/usr/lib/cyrus-imapd";
$mailstore = "/var/spool/imap"; # Cyrus mailstore
$cat = "/bin/cat";
$cmd = "/usr/bin/formail -n 20 -s $pwd/cpmsg";
$folders = "$ARGV[0]";
if (!$folders) { die "Usage: $0 filename"; }
open (MB,"$folders") || die "can't open $folders";
while (<MB>) {
chop;
# Be careful with this split - the last token might have
# whitespace we want to preserve
($user,$cyrusfolder,$folder) = split(/:/,$_,3);
@fields = split(/\./,$cyrusfolder);
$cyrfol = $fields[$#fields];
$fcat = "$cat \"$folder\"";
print $fcat;
$prefix = substr($user,0,1);
system ("$fcat | $cmd '$mailstore/$prefix/user/$user/$cyrfol'");
#print "'$mailstore/$prefix/user/$user/$cyrfol";
}
close MB;