Just to add something to the community I thought I'd share my notes on adding
my Users in bulk.
I don't know any perl so I kinda hacked my way through adding multiple users at
once on my 0.9.99 ebox.
I used the script provided by Javier. Put it in a text file called bulkusers
and made it executable for root in root's home directory.
-------------
#!/usr/bin/perl
use strict; (I deleted this line)
use warnings;
use EBox;
use EBox::Global;
EBox::init();
my $usersModule = EBox::Global->modInstance('users');
open(my $USERS,"users");
while($line = <$USERS>) {
my $user;
my ($username,$fullname,$password) = split(',',$line);
$user->{'user'} = $username;
$user->{'fullname'} = $fullname;
$user->{'password'} = $password;
push(@users,$user);
}
close($USERS);
foreach my $user (@users) {
$usersModule->addUser($user, 0);
}
1;
-----------------
Notes on this script:
a) First I got an error message
gatekeeper:~# ./bulkusers
Global symbol "$line" requires explicit package name at ./bulkusers line 13.
Global symbol "$line" requires explicit package name at ./bulkusers line 15.
Global symbol "@users" requires explicit package name at ./bulkusers line 19.
Global symbol "@users" requires explicit package name at ./bulkusers line 23.
Execution of ./bulkusers aborted due to compilation errors.
I deleted the "use scrict" line and it was fine then (since I didn't know perl
I don't know how to declare $line and @users. I'm sure purists will be not
happy with me)
Before running the script you need to have a file called 'users' in the same
directory. Inside the file it should look like the following:
-------------
jblow,Joe Blow,jblowspassword,
jdoe,Jane Doe,jdoespassword,
-------------
notes on this 'users' file
a) no blank lines or the script blows up
b) must include a trailing comma after the password (otherwise the account is
created but the password isn't added). I exported this file from excel and
thought that msdos csv file type would be what to choose but trailing commas
were not added. Apparently windows csv file type adds the trailing commas.
c) before running the script open the file in vi or something and get rid of
the trailing ^M's on the end of lines (:%s/^M$//g is the command to do this in
vi where ^M is created by pressing ctrl-v then ctrl-m)
That was it - added my users in about 3 hours of round and round discovery
about the trailing comma being needed. Once I had that figured I added 120
users in 30 seconds. Hope this helps someone else.
Jamie
reference: https://lists.warp.es/pipermail/ebox-user-es/2007-June/000280.html
_______________________________________________
Ebox-user mailing list
[email protected]
https://lists.warp.es/mailman/listinfo/ebox-user