Re: Scripting admin stuff?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks.  I shortened it to the following.  For those
using this, it needs to run as cyrus (or whatever your
cyrus user is).

#!/linus/mail/cyrus/bin/perl

$default_quota = 400000;

use Cyrus::IMAP::Admin;
use Cyrus::IMAP;

my $client = Cyrus::IMAP::Admin->new("YOUR_SERVER",143);

$client->authenticate;

@mailboxes = $client->list('%', 'user.');

foreach $mbx ( @mailboxes ) {
     @m = @$mbx;

     $client->setquota($m[0],"STORAGE",$default_quota);
}


Paul M Fleming wrote:
> Save you the work -- had to do the same thing myself.
> 
> Modify as needed - for example, i use this with Kerberos auth so no 
> username / password is used.
> 
> 
> #!/usr/bin/perl
> 
> use Cyrus::IMAP::Admin;
> use Cyrus::IMAP;
> $default_quota = 200000;
> 
> my $client = Cyrus::IMAP::Admin->new("server",143);
> $client->authenticate;
> @mailboxes = $client->list('%', 'user.');
> foreach $mbx ( @mailboxes )
> {
> 
>         @m = @$mbx;
> 
>         ($root, %quota) = $client->quotaroot($m[0]);
> 
>         $cur_usage = $quota{"STORAGE"}[0];
>         $cur_quota = $quota{"STORAGE"}[1];
> 
>         if ( defined $cur_quota )
>         {
>                 # quota defined
>                 if ( $cur_quota < $default_quota )
>                 {
>                         print "$m[0] : below default increasing\n";
>                         $client->setquota($m[0],"STORAGE",$default_quota);
>                 }
>                 if ( $cur_quota > $default_quota )
>                 {
>                         print "$m[0] : over default: $cur_quota 
> ($cur_usage / $cur_quota)\n";
>                 }
>         }
>         else
>         {
>                 print "$m[0] : NO QUOTA $cur_usage\n";
>         }
> 
> 
> 
> }
> 
> 
> On 3/26/2009 11:03 AM, Jeff Blaine wrote:
>> In 2000, I wrote a simple script that was fed to cyradm
>> to set all users quota to some value.
>>
>> It appears today that the only option to do something like
>> this is to learn the Cyrus::* Perl modules.
>>
>> Is that correct?
>> ----
>> Cyrus Home Page: http://cyrusimap.web.cmu.edu/
>> Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
>> List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html
> 
----
Cyrus Home Page: http://cyrusimap.web.cmu.edu/
Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html

[Index of Archives]     [Cyrus SASL]     [Squirrel Mail]     [Asterisk PBX]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [KDE]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux