ispman/bin ispman.bumpMailboxQuota, 1.5, 1.5.6.1 ispman.createSubMailbox, 1.3.6.1, 1.3.6.2 ispman.listOverQuotaMailboxes, 1.4, 1.4.6.1 ispman.listUserQuotas, 1.3, 1.3.6.1 ispman.warnNearQuotaMailboxes, 1.2, 1.2.6.1

Pedro Algarvio <[email protected]> Sat, 16 Sep 2006 19:20:23 +0000
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-serv13521/bin

Modified Files:
      Tag: dev_1_3-cyrus_virtdomain
	ispman.bumpMailboxQuota ispman.createSubMailbox 
	ispman.listOverQuotaMailboxes ispman.listUserQuotas 
	ispman.warnNearQuotaMailboxes 
Log Message:
Branch re-updated to current trunk. Debugging is still needed for other stuff than createMailbox and createSubMailbox.


Index: ispman.warnNearQuotaMailboxes
===================================================================
RCS file: /cvsroot/ispman/ispman/bin/ispman.warnNearQuotaMailboxes,v
retrieving revision 1.2
retrieving revision 1.2.6.1
diff -u -d -r1.2 -r1.2.6.1
--- ispman.warnNearQuotaMailboxes	30 May 2004 23:35:32 -0000	1.2
+++ ispman.warnNearQuotaMailboxes	16 Sep 2006 19:20:21 -0000	1.2.6.1
@@ -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.6.1
retrieving revision 1.3.6.2
diff -u -d -r1.3.6.1 -r1.3.6.2
--- ispman.createSubMailbox	8 Sep 2006 13:15:38 -0000	1.3.6.1
+++ ispman.createSubMailbox	16 Sep 2006 19:20:21 -0000	1.3.6.2
@@ -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,6 +28,8 @@
 use vars qw($ispman);
 $ispman = ISPMan->new();
 
+require "mailbox_actions.lib";
+
 my $uid_filter = $ARGV[0];
 my $folder     = $ARGV[1];
 my $sep         = '';
@@ -33,45 +37,19 @@
 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 ( $ISPMan::Config->{'AllowFullEmailLogins'} ) {
-            if ( $ISPMan::Config->{'CyrusUnixHierarchySep'} ) {
-                $sep = '/';
-            } else {
-                $sep = '.';
-            }
-            ( $tuid, $tdomain ) = split( '@', $uid );
-            $mailbox = join "", ( $mailbox_prefix, $tuid );
-            if ( $imap->list( join '', ( $mailbox, $sep, $folder, '@', $tdomain ) ) ) {
-                # Already Exists
-                print "$folder on $mailbox\@$tdomain already exists. Skipping\n";
-            } else {
-                my $tmailbox = join '', ( $mailbox, '@', $tdomain );
-                try( $imap->set_acl( $tmailbox, $admin, "lrswipdca" ) );
-                print "Creating $folder on $mailbox\@$tdomain\n";
-                my $tmailbox = join '', ( $mailbox, $sep, $folder, '@', $tdomain );
-                try( $imap->create( $tmailbox ) );
-            }
-        } else {
-            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.5.6.1
diff -u -d -r1.5 -r1.5.6.1
--- ispman.bumpMailboxQuota	5 Jun 2004 12:45:18 -0000	1.5
+++ ispman.bumpMailboxQuota	16 Sep 2006 19:20:21 -0000	1.5.6.1
@@ -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.3.6.1
diff -u -d -r1.3 -r1.3.6.1
--- ispman.listUserQuotas	30 May 2004 23:35:32 -0000	1.3
+++ ispman.listUserQuotas	16 Sep 2006 19:20:21 -0000	1.3.6.1
@@ -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.4.6.1
diff -u -d -r1.4 -r1.4.6.1
--- ispman.listOverQuotaMailboxes	30 May 2004 23:35:32 -0000	1.4
+++ ispman.listOverQuotaMailboxes	16 Sep 2006 19:20:21 -0000	1.4.6.1
@@ -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