Koozali.org: home of the SME Server
Legacy Forums => General Discussion (Legacy) => Topic started by: Ivan Haefele on April 23, 2002, 06:26:17 PM
-
Need to add several thousand user-names, several hundred group-names, make users part of groups, etc., and am battling . . .
I have tried script as per Darryl May (Thanks), but don't seem to be able 2 get it 2 work properly with SME v5.1.2
After running script, 'db show accounts' lists the added account and pseudonyms, but /home directory is not created, unix account is not created, password not set, ldap and httpd not updated??? What am I doing wrong??
Herewith modded script to add students:-
#!/bin/sh
#
# USAGE:
#
# Create the file /root/stlist.txt in the following format:
#
# USERNAME1
#
# and so on...
#
# This script will create user accounts, mail accounts and pseudonyms for
# all the listed users in the /root/stlist.txt file.
#
# NOTE *By default usernames/passwords are set to the same value*
#
UFILE=$1
if [ ! -f $UFILE ]; then
echo User database $UFILE missing
exit
fi
# export record=cat $UFILE
# if [ "$record" != "" ]; then
# --------------------------
# Make sure the lines below are all indented as shown
# --------------------------
for record in cat $UFILE
do
user=echo $record | awk -F"," {'print $1'}
firstname=student
lastname=echo $record | awk -F"," '{print "#" substr($1,2,length($1))}'
uid=echo $record | awk -F"," '{print substr($1,4)}'
number=$RANDOM
# ----------------------
# Set values for account
# ----------------------
#
# Available values and options are shown below as 'option' :
#
# FirstName $firstname
# LastName $lastname
# Dept 'department'
# Company 'company name'
# Street 'address'
# City 'city, postal, prov/state, country'
# Phone 'phone number'
# EmailForward 'local, forward, both'
# ForwardAddress 'leave blank or enter forward address'
#
# Below are the minimum values with no changes required
#
/sbin/e-smith/db accounts set UserName $user FirstName $firstname LastName $lastname PasswordSet yes Uid $uid Gid $number
# ---------------
# Create e-smith Account
# ---------------
/sbin/e-smith/signal-event user-create $user
# tried adding this - error on
# unless db_get_type(\%accounts, $username) eq "user" - line 47
# Create Unix Acct
/etc/e-smith/events/user-create/S15user-create-unix UserName $user
# ---------------
# Pause Script, bug reported by Jeffrey Smith
# ---------------
sleep 9
# ----------------
# Create Password
# -----------------------------------------------------
# (in this case the username and password are the same)
# eg: ( '$username', 'PASSWORD' );"
# -----------------------------------------------------
perl -e "use esmith::util; esmith::util::setUserPassword ( '$user',
'$user' );"
# ---------------------------------
# Set value for password as created
# ---------------------------------
/sbin/e-smith/db accounts setprop $user PasswordSet yes
# ---------------------------------------------------------
# Create Pseudonym (FIRSTNAME.LASTNAME@domain.org)
# Create Pseudonym (FIRSTNAME_LASTNAME@domain.org)
# (simple comment these lines out to not create Pseudonyms)
# ---------------------------------------------------------
/sbin/e-smith/signal-event pseudonym-create $firstname.$lastname $user
/sbin/e-smith/signal-event pseudonym-create $firstname_$lastname $user
done
input file looks like :-
s970871234
to give
Account Name : s970871234
First Name : student
Last Name : # 970871234
password : s97081234
Been at this for a week now - would appreciate some help :-0
Thanks,
Ivan
-
Shouldn't your input file be laid out:
# USERNAME1:FIRSTNAME1:LASTNAME1
# USERNAME2:FIRSTNAME2:LASTNAME2 ??
and you have '$user' in the place where Darrell's script has simply 'user'
The correct line is:
/sbin/e-smith/db accounts set $username user FirstName $firstname LastName $lastname PasswordSet no Uid $number Gid $number
-
Sorted! - well - sort of . . .
Input file *must* be in DOS format, i.e. cr/lf to work. I had userlist.txt in unix form, and that screwed it up . . .
Now adding student accounts, names. Script adds about 2 users per minute - adding 3138 at this time.
Now, does anyone have any ideas about adding the groups?????
(138 off)
Thanx,
Ivan
-
Sorted! - well - sort of . . .
Input file *must* be in DOS format, i.e. cr/lf to work. I had userlist.txt in unix form, and that screwed it up . . .
Now adding student accounts, names. Script adds about 2 users per minute - adding 3138 at this time.
Now, does anyone have any ideas about adding the groups?????
(138 off)
Thanx,
Ivan
-
You may want to back up a bit, there is a limit (28) as to how many groups can be added to the server. Check this link...
http://forums.contribs.org/index.php?topic=12515.msg46988#msg46988
-
test this tarball
http://educatux.dnsalias.org/e-smith/multicount.tgz
command : tar zxvf multicount.tgz -C /
This package is french. We are currently developping.
Stéphane GAUTIER
stephane.gautier@ac-orleans-tours.fr