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

[cobalt-users] Mass User Addition Script for RAQ3i



Hello,

Following script is developed by me with the help of Cobalt Tech Support.
This works fine.

----------------------------------------------
#!/usr/bin/perl

# pass a comma separated list of
#
# username,fullname,password
#

use Getopt::Std;
require Cobalt::User;
use Cobalt::Meta;

my $addfile = '/tmp/users.dat'; # the file which contains the users to be
added
my $group = "site1"; # Change the group to the one for Virtual Site you
wanted
my $quota = 5;       # Disk quota in MB
my $fpx = "off";     # Front Page Support
my $apop = "off";    # Apop support
my $admin = "off";   # User is admin or not
my $shell = "off";   # allow shell access
open IN, $addfile;
flock (IN,2);
@userdata = <IN>;
close IN;
foreach $usr (@userdata) {
    chomp($usr);
    ($username, $name, $passwd) = split(/\,/,$usr);
 print "creating $username.. ";
 my $m = Cobalt::Meta->new("type" => "users",
      "name" => "$username",
      "group" => "$group",
      "fullname" => "$name",
      "altname" => "",
      "password1" => "$passwd",
      "password2" => "$passwd",
      "quota" => "$quota",
      "fpx" => "$fpx",
      "apop" => "$apop",
      "shell" => "$shell",
      "admin" => "$admin",
      "suspend" => "",
      "aliases" => "",
      "forward" => "",
      "vacation" => "",
      "vacationmsg" => "");
 my $res = &Cobalt::User::site_user_add($m);
 if ($res) {
     print "  ERROR: $res\n";
 } else {
     print "ok\n";
 }
}

=================================

Please change appropriate places for your environment.

THe users I added are visible thru the GUI.

Hope this helps.

Vijay Nair

www.trichurgateway.com