Appendix A. Conversion from Berkeley Mail Format to Cyrus: Tools
The procedure for converting a set of users from traditional Unix (Berkeley format) mail to Cyrus was outlined in Chapter 9, Cyrus System Administration . In this appendix, source code for the tools used in such a conversion is provided.
bsd2cyrus
bsd2cyrus is a Perl script, introduced in Chapter 9 , that maps a set of usersâ Berkeley-format mail folders into the Cyrus namespace. The output of the bsd2cyrus script is used as input to other scripts that are used in converting users from a Berkeley-style mail system to a Cyrus system. bsd2cyrus takes as input the filename of a text file that contains a list of usernames. Example A-1 shows the bsd2cyrus script.
Example A-1. bsd2cyrus
#!/usr/local/bin/perl eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' if $running_under_some_shell; require "find.pl"; $inputfile = "$ARGV[0]"; if (! $inputfile) { die "Usage: $0 inputfile\\n"; }
For each user, get the userâs home directory from the passwd
file and search for the pathnames of all files under the userâs ~/mail
directory. The find
subroutine pushes those files onto an array. Note that the files are all pushed onto a single array, not an array per userâthis is because weâre assuming that youâre converting a large batch of users all at one time and donât need to do anything special on a per-user basis.
open (DATA, $inputfile) || die "can't open $inputfile"; while (<DATA>) { chop; ($user,$pw,$uid,$gid,$quota,$cmnt,$gcos,$home) ...
Get Managing IMAP now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.