ispman/bin ispman.bumpMailboxQuota, 1.5, 1.6 ispman.createSubMailbox, 1.3, 1.4 ispman.listOverQuotaMailboxes, 1.4, 1.5 ispman.listUserQuotas, 1.3, 1.4 ispman.warnNearQuotaMailboxes, 1.2, 1.3

Joerg Delker <[email protected]>
Newsgroups gmane.comp.isp.ispman.cvs
Message-ID <[email protected]>
Update of /cvsroot/ispman/ispman/bin
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv5983/bin

Modified Files:
	ispman.bumpMailboxQuota ispman.createSubMailbox 
	ispman.listOverQuotaMailboxes ispman.listUserQuotas 
	ispman.warnNearQuotaMailboxes 
Log Message:
updated mail cli tools to new mailbox_actions.lib

Index: ispman.warnNearQuotaMailboxes
===================================================================
RCS file: /cvsroot/ispman/ispman/bin/ispman.warnNearQuotaMailboxes,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ispman.warnNearQuotaMailboxes	30 May 2004 23:35:32 -0000	1.2
+++ ispman.warnNearQuotaMailboxes	12 Sep 2006 13:09:08 -0000	1.3
@@ -6,18 +6,26 @@
     use FindBin;
     unshift @INC,
       ( $FindBin::Bin, "$FindBin::Bin/../lib", "$FindBin::Bin/../conf" );
+    use Getopt::Std;
+    getopt( 'h', \%opts );
+    unless ( $opts{'h'} ) {
+        $0 =~ s/.*\///;
+        print "Usage: $0 -h imap_server\n";
+        exit;
+    }
 }
 
 #Customize these 2 lines and the message at the bottom of the script
 $mail{smtp} = [qw(mail.example.com)];
 $mail{from} = 'CompanyName Email Postmaster <[email protected]>';
 
-require "cyrusadmin.pm";
 use ISPMan;
 use Mail::Sendmail;
 use vars qw($ispman);
 $ispman = ISPMan->new();
 
+require "mailbox_actions.lib";
+
 #Default to 60% of quota
 my $percent    = 60;
 my $multiplier = $percent / 100;
@@ -29,10 +37,9 @@
     @uids = $ispman->as_array( $users->{$_}{'uid'} );
 
     #We want the user_example_com uid
-    if ( $uids[0] =~ /@/ ) { $uid = $uids[1]; }
-    else { $uid = $uids[0]; }
-    $mailbox = join "", ( $mailbox_prefix, $uid );
-    @q = $imap->get_quota($mailbox);
+    if   ( $uids[0] =~ /@/ ) { $uid = $uids[1]; }
+    else                     { $uid = $uids[0]; }
+    @q = get_quota( $opts{'h'}, $uid );
     next unless $q[2];
     $threshold = $multiplier * $q[2];
 
@@ -50,7 +57,7 @@
 
         #Customize here, don't forget escapes amd put it all on one line
         $mail{message} =
-"Your email box is at $percent% of your email quota.\nYour Quota is:  $q[2] kilo bytes\nYou have Used:  $q[1] kilobytes\n\nPlease dump your trash and erase unneeded email. If you need more space, please contact our office at hosting-support\@example.com. There may be an additional charge.\nOnce y our mailbox is full, no more mail will be delivered until some email is erased.\nNOTE: You will receive this alert once a day if your mailbox is in danger of being full.";
+          "Your email box is at $percent% of your email quota.\nYour Quota is:  $q[2] kilo bytes\nYou have Used:  $q[1] kilobytes\n\nPlease dump your trash and erase unneeded email. If you need more space, please contact our office at hosting-support\@example.com. There may be an additional charge.\nOnce y our mailbox is full, no more mail will be delivered until some email is erased.\nNOTE: You will receive this alert once a day if your mailbox is in danger of being full.";
 
         sendmail(%mail) or die $Mail::Sendmail::error;
     }

Index: ispman.createSubMailbox
===================================================================
RCS file: /cvsroot/ispman/ispman/bin/ispman.createSubMailbox,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ispman.createSubMailbox	5 Jun 2004 12:45:18 -0000	1.3
+++ ispman.createSubMailbox	12 Sep 2006 13:09:08 -0000	1.4
@@ -9,15 +9,17 @@
     use FindBin;
     unshift @INC,
       ( $FindBin::Bin, "$FindBin::Bin/../lib", "$FindBin::Bin/../conf" );
-    require "cyrusadmin.pm";
-    unless ( $ARGV[1] ) {
-        print "I need 2 parameters\n";
-        print "uid_filter: such as '*' or '*_some_domain'\n";
-        print "mailbox:  the submailbox to create under INBOX\n";
+    use Getopt::Std;
+    getopt( 'h', \%opts );
+    unless ( $opts{'h'} ) {
+        $0 =~ s/.*\///;
+        print "Usage: $0 -h imap_server uidexpr folder\n";
+        print "uidexpr: such as 'blafasel', '*' or '*_some_domain'\n";
+        print "folder: the folder to create under INBOX\n";
         exit;
     }
     if ( $ARGV[1] =~ /[^a-z0-9-_]/i ) {
-        print "bad mailbox syntax. Only a-z, A-Z, 0-9, - , _ allowed\n";
+        print "bad folder syntax. Only a-z, A-Z, 0-9, - , _ allowed\n";
         exit;
     }
 }
@@ -26,34 +28,27 @@
 use vars qw($ispman);
 $ispman = ISPMan->new();
 
+require "mailbox_actions.lib";
+
 my $uid_filter = $ARGV[0];
 my $folder     = $ARGV[1];
 
 my $users = $ispman->getEntriesAsHashRef( $ispman->{'Config'}{'ldapBaseDN'},
     "&(objectclass=ispmanDomainUser)(uid=$uid_filter)" );
 
-USER: for ( keys %$users ) {
-    @uids    = $ispman->as_array( $users->{$_}{'uid'} );
-    $uid     = $uids[0];
-    $mailbox = join "", ( $mailbox_prefix, $uid );
-    if ( $imap->list($mailbox) ) {
-
-        # mailbox exists. Lets continue
-
-        if ( $imap->list( join '.', ( $mailbox, $folder ) ) ) {
-
-            # Already Exists
-            print "$folder on $mailbox already exists. Skipping\n";
-        }
-        else {
-            try( $imap->set_acl( $mailbox, $admin, "lrswipdca" ) );
-            print "Creating $folder on $mailbox\n";
-            try( $imap->create( join '.', ( $mailbox, $folder ) ) );
-        }
+for ( keys %$users ) {
+    @uids = $ispman->as_array( $users->{$_}{'uid'} );
+    $uid  = $uids[0];
 
+    my $rc = create_folder( $opts{'h'}, $uid, $folder );
+    if ( $rc == 0 ) {
+        print "Folder $folder was successfully created.\n";
+        exit 0;
     }
     else {
-        print "Skipping $mailbox. It does not exists\n";
+        print "Error: Folder $folder could not be created (rc=$rc)!\n";
+        exit $rc;
     }
 }
 
+__END__

Index: ispman.bumpMailboxQuota
===================================================================
RCS file: /cvsroot/ispman/ispman/bin/ispman.bumpMailboxQuota,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ispman.bumpMailboxQuota	5 Jun 2004 12:45:18 -0000	1.5
+++ ispman.bumpMailboxQuota	12 Sep 2006 13:09:08 -0000	1.6
@@ -11,14 +11,21 @@
     use FindBin;
     unshift @INC,
       ( $FindBin::Bin, "$FindBin::Bin/../lib", "$FindBin::Bin/../conf" );
+    use Getopt::Std;
+    getopt( 'h', \%opts );
+    unless ( $opts{'h'} ) {
+        $0 =~ s/.*\///;
+        print "Usage: $0 -h imap_server\n";
+        exit;
+    }
 }
 
-require "cyrusadmin.pm";
-
 use ISPMan;
 use vars qw($ispman);
 $ispman = ISPMan->new();
 
+require "mailbox_actions.lib";
+
 my $uid_filter = $ARGV[0] || '*';
 my $bytes      = $ARGV[1] || 1024;
 
@@ -26,18 +33,17 @@
     "&(objectclass=ispmanDomainUser)(uid=$uid_filter)" );
 
 USER: for ( keys %$users ) {
-    @uids    = $ispman->as_array( $users->{$_}{'uid'} );
-    $uid     = $uids[0];
-    $mailbox = join "", ( $mailbox_prefix, $uid );
-    @q       = $imap->get_quota($mailbox);
+    @uids = $ispman->as_array( $users->{$_}{'uid'} );
+    $uid  = $uids[0];
+    @q    = get_quota( $opts{'h'}, $uid );
     next unless $q[2];
     if ( $q[1] >= $q[2] ) {
         print
-"$uid is over quota. Quota:  $q[2] , Used:  $q[1], Over @{[$q[1]-$q[2]]}.\n";
+          "$uid is over quota. Quota:  $q[2] , Used:  $q[1], Over @{[$q[1]-$q[2]]}.\n";
         print "Bumping up $bytes bytes\n";
         $newQuota = $q[2] + $bytes;
         print "New Quota: $newQuota\n";
-        try( $imap->set_quota( $mailbox, $newQuota ) );
+        set_quota( $opts{'h'}, $uid, $newQuota );
     }
 }
 

Index: ispman.listUserQuotas
===================================================================
RCS file: /cvsroot/ispman/ispman/bin/ispman.listUserQuotas,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ispman.listUserQuotas	30 May 2004 23:35:32 -0000	1.3
+++ ispman.listUserQuotas	12 Sep 2006 13:09:08 -0000	1.4
@@ -6,14 +6,22 @@
     use FindBin;
     unshift @INC,
       ( $FindBin::Bin, "$FindBin::Bin/../lib", "$FindBin::Bin/../conf" );
+    use Getopt::Std;
+    getopt( 'h', \%opts );
+    unless ( $opts{'h'} ) {
+        $0 =~ s/.*\///;
+        print "Usage: $0 -h imap_server\n";
+        exit;
+
+    }
 }
 
-use lib qw(%%installDir%%/lib);
-require "cyrusadmin.pm";
 use ISPMan;
 use vars qw($ispman);
 $ispman = ISPMan->new();
 
+require "mailbox_actions.lib";
+
 my $uid_filter = $ARGV[0] || '*';
 
 my $users = $ispman->getEntriesAsHashRef( $ispman->{'Config'}{'ldapBaseDN'},
@@ -24,8 +32,7 @@
     $uid       = $uids[0];
     $mailQuota = $users->{$_}{'mailQuota'};
     $ftpQuota  = $users->{$_}{'FTPQuotaMBytes'};
-    $mailbox   = join "", ( $mailbox_prefix, $uid );
-    @q         = $imap->get_quota($mailbox);
+    @q         = get_quota( $opts{'h'}, $uid );
 
     write();
 

Index: ispman.listOverQuotaMailboxes
===================================================================
RCS file: /cvsroot/ispman/ispman/bin/ispman.listOverQuotaMailboxes,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ispman.listOverQuotaMailboxes	30 May 2004 23:35:32 -0000	1.4
+++ ispman.listOverQuotaMailboxes	12 Sep 2006 13:09:08 -0000	1.5
@@ -7,27 +7,34 @@
     use FindBin;
     unshift @INC,
       ( $FindBin::Bin, "$FindBin::Bin/../lib", "$FindBin::Bin/../conf" );
+    use Getopt::Std;
+    getopt( 'h', \%opts );
+    unless ( $opts{'h'} ) {
+        $0 =~ s/.*\///;
+        print "Usage: $0 -h imap_server\n";
+        exit;
+    }
 }
 
-require "cyrusadmin.pm";
 use ISPMan;
 use vars qw($ispman);
 $ispman = ISPMan->new();
 
+require "mailbox_actions.lib";
+
 my $uid_filter = $ARGV[0] || '*';
 
 my $users = $ispman->getEntriesAsHashRef( $ispman->{'Config'}{'ldapBaseDN'},
     "&(objectclass=ispmanDomainUser)(uid=$uid_filter)" );
 
 USER: for ( keys %$users ) {
-    @uids    = $ispman->as_array( $users->{$_}{'uid'} );
-    $uid     = $uids[0];
-    $mailbox = join "", ( $mailbox_prefix, $uid );
-    @q       = $imap->get_quota($mailbox);
+    @uids = $ispman->as_array( $users->{$_}{'uid'} );
+    $uid  = $uids[0];
+    @q    = get_quota( $opts{'h'}, $mailbox );
     next unless $q[2];
     if ( $q[1] >= $q[2] ) {
         print
-"$uid is overquota. Quota:  $q[2] , Used:  $q[1], Over @{[$q[1]-$q[2]]}.\n";
+          "$uid is overquota. Quota:  $q[2] , Used:  $q[1], Over @{[$q[1]-$q[2]]}.\n";
     }
 }
 


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.