Go to CPAN and download and IMAP::Admin.  All our accounts are created 
via automated processes in perl, and that's what I use.  You can create 
and delete users, set ACLs and quota roots.  It's also partition aware.

-- Rob

--On Monday, November 27, 2000 04:11:07 PM -0700 Darron Froese 
<[EMAIL PROTECTED]> wrote:

> On 11/27/00 12:19 PM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
>> Is there an easy way to invoke the perl cyradm from a script to
>> create mailboxes for new users?  I'd like to incorporate this into
>> our account creation scripts to do a few simple things such as
>> create the mailbox and set the quota.  Would it be better to use
>> the underlying perl library instead?  I'd like to put the
>> administrator's username and password, and the server name into a
>> file, and have the rest of the information fed from the script.
>
> I've gotten around this (with the older non-perl cyradm) by creating
> an expect script to add my users automatically and set the mailbox
> quota. I don't expect this would be much different for the Perl
> version.
>
> All I do is give the script the username as an argument and it does
> the rest.
>
> Here it is:
>
> #!/usr/bin/expect
>
> set force_conservative 1  ;# set to 1 to force conservative mode even
> if ;# script wasn't run conservatively originally
> if {$force_conservative} {
>     set send_slow {1 .1}
>     proc send {ignore arg} {
>         sleep .1
>         exp_send -s -- $arg
>     }
> }
>
> set username [lrange $argv 0 0]
>
> set timeout 2
>
> # Start the program.
> spawn /usr/local/cyrus-imapd-1.6.24/bin/cyradm -user mailadmin
> localhost match_max 100000
>
> # Look for the Password: line and send the password.
> expect -exact "Password: "
> send -- "password\r"
> expect -exact "\r
> localhost.localdomain> "
>
> # Create the mailbox user.$username.
> send -- "cm user.$username\r"
> expect -exact "cm user.$username\r
> localhost.localdomain> "
>
> # Set the quota to 200MB. That should be enough.
> send -- "sq user.$username 200000\r"
> expect -exact "sq user.$username 200000\r
> localhost.localdomain> "
>
> #
> send -- "quit\r"
> expect eof
>
>
>
> You may already have expect on your system, if you run the utility
> "autoexpect" it will watch what you're doing and create a script for
> you (that you can modify however you'd like after).
> --
> Darron
> [EMAIL PROTECTED]
>




       _ _ _ _           _    _ _ _ _ _
      /\_\_\_\_\        /\_\ /\_\_\_\_\_\
     /\/_/_/_/_/       /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
    /\/_/__\/_/ __    /\/_/    /\/_/          PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_/    /\/_/
  /\/_/ \/_/  /\/_/_/\/_/    /\/_/         (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/     \/_/              appears profound)

  Rob Tanner
  UNIX and Networks Manager
  Linfield College, McMinnville OR
  (503) 434-2558 <[EMAIL PROTECTED]>


Reply via email to