38f2261
#!/usr/bin/perl
38f2261
#
38f2261
# Usage:	inboxfer inputfile
38f2261
#
38f2261
# Purpose:	Transfer messages from Berkeley-format inbox to Cyrus inbox
38f2261
#
38f2261
# Input:	Text file containing one username per line
38f2261
#
38f2261
# Warning:	Do not use this script to transfer messages into a Cyrus 
38f2261
#		mailbox that already contain messages. Existing messages 
38f2261
#		will be overwritten.
38f2261
#
38f2261
#$Id: inboxfer,v 1.1 2005/04/15 20:24:15 jdennis Exp $
38f2261
38f2261
$mailstore = "/var/spool/imap";  # Cyrus mailstore
38f2261
$oldspool  = "/var/spool/mail";       # Old mail spool
38f2261
$cat       = "/bin/cat";              # /usr/bin/cat on Solaris
38f2261
$formail   = "/usr/bin/formail";
38f2261
$pwd       = "/usr/lib/cyrus-imapd";
38f2261
$cpmsg     = "cpmsg";               
38f2261
38f2261
$cmd       = "$formail -n 20 -s $pwd/$cpmsg";
38f2261
38f2261
$users = "$ARGV[0]";
38f2261
if (!$users) { die "Usage: $0 $users\n"; }
38f2261
38f2261
open(USERS,"$users") || die "can't open $users";
38f2261
38f2261
while (<USERS>) {
38f2261
    chop;
38f2261
    $inbox = "$oldspool/$_";
38f2261
    $prefix = substr($_,0,1);
38f2261
    system("$cat $inbox | $cmd $mailstore/$prefix/user/$_");
38f2261
}
38f2261
38f2261