--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/im Fri Nov 04 06:29:26 2005 +0000
@@ -0,0 +1,53 @@
+#! /usr/bin/perl
+# © 2005 Heiko Schlittermann
+# $Id$
+# $URL$
+
+# small template for action on all imap folders
+# or simlar quatsch
+
+use strict;
+use warnings;
+use AppConfig;
+
+use Mail::IMAPClient;
+use Cyrus::IMAP::Admin;
+
+use constant QUOTA => 200000; # kiloByte
+
+use constant CONFIG => (
+ { CASE => 1 },
+ quota => { DEFAULT => 200000, ARGS => "=i" },
+ force => { DEFAULT => undef, ARGS => "!" },
+);
+
+my $Cf = new AppConfig CONFIG;
+ $Cf->getopt(\@ARGV);
+
+my $imap = new Cyrus::IMAP::Admin("localhost") or die;
+# $imap->authenticate(-user => "root", -password => "hallo") or die;
+$imap->authenticate(-user => "root") or die;
+
+foreach ($imap->list("user/*")) {
+ my ($mb, $att, $sep) = @$_;
+
+ next unless $mb =~ /^user\/[^\/]+$/;
+ print "$mb";
+
+ my ($qroot, $quota) = $imap->listquotaroot($mb);
+ if ($qroot && $qroot ne $mb) {
+ print " QuotaRoot; $qroot\n";
+ next;
+ }
+
+ my %q = $imap->listquota($mb);
+ if (exists $q{STORAGE} and !$Cf->force) {
+ my ($used, $max) = @{$q{STORAGE}};
+ print " Quota $used/$max " . int($used/$max*100) . "%";
+ } else {
+ $imap->setquota($mb, "STORAGE" => $Cf->quota) or die;
+ }
+
+ print "\n";
+
+}