find `/usr/bin/perl -e 'print "@INC"'` -name '*.pm' -print
To use this script you need IMAP::Admin.
$ wget http://search.cpan.org/CPAN/authors/id/E/EE/EESTABROO/IMAP-Admin-1.6.4.tar.gz $ tar xzf IMAP-Admin-1.6.4.tar.gz $ cd IMAP-Admin-1.6.4/ $ perl Makefile.pl $ make $ su - make install
#!/usr/bin/perl -w # # cyrus_user.pl # # This script will create user mailboxes for cyrus imapd. # # Copyright (c) 2006 Voelcker Informatik AG. All rights reserved. This # programm is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # # -andrer, 2006 Voelcker Informatik AG, <andrer@voelcker.com> # # $Id$ # # $LastChangedDate$ # use warnings; use IMAP::Admin; use Getopt::Std; my $server = 'localhost'; my $port = 143; my $admin = 'cyrus'; my $pass = 'cyrus'; my $quota = 10000; my $acl = 'lrswipcda'; my @subfolders = ( "drafts", "sent-mail", "spam", "trash", ); my %opts = (); getopts('cdS:P:a:p:q:r:s:h', \%opts); if (scalar(@ARGV) < 1) { &usage; exit; } if( $opts{S} ) { $server = $opts{S} ; } if( $opts{P} ) { $port = $opts{P} ; } if( $opts{a} ) { $admin = $opts{a} ; } if( $opts{p} ) { $pass = $opts{p} ; } if( $opts{q} ) { $quota = $opts{q} ; } if( $opts{r} ) { $acl = $opts{r} ; } if( $opts{s} ) { @subfolders = split(/,/,$opts{s}) ; } if( ($opts{c} && $opts{d}) ) { &usage; } if( $opts{h} ) { &usage; } sub usage { if ($_ = shift) { print STDERR "${0}: $_\n"; } print STDERR " ${0} - add or delete cyrus user mailbox (c) 2006 Voelcker Informatik AG, <andrer\@voelcker.com> Version: 0.42\n Usage: ${0} (-cdSPapsqrh) mailbox [mailbox ...]\n -c Create Mailbox(s) -d Delete Mailbox(s) -S <Server> Default is 'localhost' -P <Port> Default is '143' -a <Admin user> Default is 'cyrus' -p <Admin password> Default is 'cyrus' -s <Set default subfolders> Default is 'drafts,sent-mail,spam,trash' -q <Quota> Default is '10000' (10 MByte) -r <Set admin rights for mailbox> Default is 'lrswipcda' (all) -h Print this message.\n\n"; exit(1); } sub error { my($mesg) = shift || $!; my($exit) = shift || 0; print STDERR "${0}: ${mesg}\n"; exit($exit) if $exit > 0; } sub screate { $imap = IMAP::Admin->new('Server' => $server, 'Login' => $admin, 'Password' => $pass, 'Port' => $port, ); foreach $mailbox (@ARGV) { $err = $imap->create($mailbox); if ($err != 0) { &error("Can't create mailbox $mailbox\n$imap->{'Error'}\n",1); } foreach $folder (@subfolders) { $err = $imap->create("$mailbox/$folder"); if ($err != 0) { &error("Can't create mailbox subfolder $mailbox\/$folder\n$imap->{'Error'}\n",1); } } $err = $imap->set_quota($mailbox, $quota); if ($err != 0) { &error("Can't set quota for mailbox $mailbox with size $quota\n$imap->{'Error'}\n",1); } $err = $imap->set_acl($mailbox, $admin, $acl); if ($err != 0) { &error("Can't set acl for mailbox $mailbox\n$imap->{'Error'}\n",1); } } $imap->close; exit(0); } sub sdelete { $imap = IMAP::Admin->new('Server' => $server, 'Login' => $admin, 'Password' => $pass, 'Port' => $port, ); foreach $mailbox (@ARGV) { $err = $imap->delete($mailbox); if ($err != 0) { &error("Can't delete mailbox $mailbox\n$imap->{'Error'}\n",1); } } exit(0); } &usage; exit(0); __END__ =pod =head1 NAME cyrus_user.pl - add or delete cyrus user mailbox (c) 2006 Voelcker Informatik AG, <andrer\@voelcker.com> Version: 0.42 =head1 DESCRIPTION Create or delete multiple user mailboxes for cyrus imapd. Feel free to specify as many mailboxes you like. Bugs, requests and comments are welcome. Send them to: <andrer@voelcker.com>. =head1 OPTIONS =over 10 =item -c Create one or more mailbox. =item -d Delete one or more mailbox. =item -S Specify the IP Address or FQDN of the server were cyrus imapd is installed. Default is 'localhost'. =item -P Specify the Port number were cyrus imapd is listening on. Default is '143'. =item -a Give a name for the cyrus admin user. Default is 'cyrus'. =item -p Give a password for the cyrus admin user. Default is 'cyrus'. =item -s Give optional subfolders for every mailbox you specified. Just add them comma separated. Remember that they will be added with '/' to the mailbox. Default is 'drafts,sent-mail,spam,trash'. =item -q Changes the default quota for each mailbox. Default is '10000' kByte. =item -r Changes the default access control rights for the admin user for each mailbox. ACL rights are defined as: l = lookup r = read s = keep seen/unseen information accross sessions w = write i = insert p = post c = create d = delete a = administer These flags can be combined to general rules like: lrs = read lrsp = post lrsip = append lrswipcd = write lrswipcda = all =item -h This will show a short helping message. =back =head1 PREREQUISITES In order to use this script you need C<IMAP::Admin>. Go for a search on cpan.org. =head1 SCRIPT CATEGORIES UNIX/System_administration =head1 BUGS Feel free to submit. <andrer@voelcker.com> =head1 LICENSE This programm is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Please refer to the Perl license for details. =head1 AUTHOR Andre Raabe <andrer@voelcker.com> Copyright (c) 2006 Voelcker Informatik AG. All rights reserved. =cut EOF