[vhffs-dev] [1440] A little tool for batch popbox creation

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1440
Author:   beuss
Date:     2009-06-15 17:15:59 +0200 (Mon, 15 Jun 2009)

Log Message:
-----------
A little tool for batch popbox creation

Added Paths:
-----------
    trunk/vhffs-tools/src/vhffs-box-add


Added: trunk/vhffs-tools/src/vhffs-box-add
===================================================================
--- trunk/vhffs-tools/src/vhffs-box-add	                        (rev 0)
+++ trunk/vhffs-tools/src/vhffs-box-add	2009-06-15 15:15:59 UTC (rev 1440)
@@ -0,0 +1,31 @@
+#!%PERL% -w
+# Adds boxes in command line (for batch imports)
+# Takes domain name, local part and clear text password
+# as arguments.
+# Die if something goes wrong.
+# Dedicated to Samuel Lesueur :-)
+
+use strict;
+
+use lib '%VHFFS_LIB_DIR%';
+
+use Vhffs::Main;
+use Vhffs::Functions;
+use Vhffs::Group;
+use Vhffs::Services::Mail;
+use Vhffs::User;
+
+my $vhffs = init Vhffs::Main;
+
+die("Usage $0 maildomain local_part password\n") unless(@ARGV == 3);
+
+my $domain = Vhffs::Services::Mail::get_by_mxdomain( $vhffs, $ARGV[0] );
+die 'Invalid domain specified ('.$ARGV[0].')' unless(defined $domain);
+
+my $rval = $domain->addbox($ARGV[1], $ARGV[2]);
+die( 'Invalid address' )	 if($rval == -1);
+die( 'Address already exists' )  if( $rval == -2 );
+die( 'Error while adding box' )  if( $rval == -3 );
+
+print "$ARGV[1]\@$ARGV[2] added. Do not forget to launch mail_createboxes.pl\n";
+


Property changes on: trunk/vhffs-tools/src/vhffs-box-add
___________________________________________________________________
Name: svn:executable
   + *


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/