Koozali.org: home of the SME Server
Legacy Forums => Experienced User Forum => Topic started by: Ivan Haefele on April 23, 2002, 07:18:26 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 Darrel 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
s960565332
To give
Account Name : s970871234
First Name : student
Last Name : # 970871234
password : s97081234
uid : 81234
Been at this for a week now - would appreciate some help :-0
Thanks,
Ivan
-
Hi Ivan,
>Need to add several thousand user-names, several hundred group-names,
> make users part of groups,
I'm no expert but I seem to remember reading that there is a limit of 28 groups only in SME. I could be mistaken. I'd suggest a quick search of the forums on groups.
Kelvin
-
I just tried it tonight. The user is added to the user list in the server-manager, but the password must be reset to access email. (I commented the pseudonyms, but I don't believe that has anything to do with logging in under the username)
-
Hi, Steve
Did you try script as I modded it, or Darrel's original - what version e-smith are you running??
Thanks,
Ivan
-
Hi, Steve
Did you try script as I modded it, or Darrel's original - what version e-smith are you running??
Thanks,
Ivan
-
I didn't realize you had changed it. After reading it just now, I did notice you have made several mod.'s! I used Darrel's orginal.
-
Where is your updated one?.... i tried a script (think original) but it did'nt work, so I ended up adding 1000+ accounts by hand, it tooks 2 days.
add,
update password
check login
painful! ;-((
-
Where is your updated one?.... i tried a script (think original) but it did'nt work, so I ended up adding 1000+ accounts by hand, it tooks 2 days.
add,
update password
check login
painful! ;-((
-
Does anyone have a working script as I also need one to add hundreds of students. I am running E-Smith 5.0.....(not wanting to upgrade at the moment) and the one provided at
http://myezserver.com/downloads/mitel/howto/addusers-howto.html
brings up many errors and doesn't add the users see the following examples/root/e-smith-adduser.sh: PasswordSet: command not found
Failed to set Unix password for account .
/sbin/e-smith/db dbfile setprop key prop1 val1 [prop2 val2] [prop3 val3] ...
/sbin/e-smith/db dbfile set key type [prop1 val1] [prop2 val2] ...
/root/e-smith-adduser.sh: PasswordSet: command not found
Failed to set Unix password for account johnstonn.
/root/e-smith-adduser.sh: PasswordSet: command not found
Failed to set Unix password for account .
/sbin/e-smith/db dbfile setprop key prop1 val1 [prop2 val2] [prop3 val3] ...
/sbin/e-smith/db dbfile set key type [prop1 val1] [prop2 val2] ...
/root/e-smith-adduser.sh: PasswordSet: command not found
Failed to set Unix password for account lancastert.
/root/e-smith-adduser.sh: PasswordSet: command not found
-
Toby, I've used Darrell's script successfully in the past. It looks like you goofed entering it, and had a line wrap improperly, probably this one:
/sbin/e-smith/db accounts set $username user FirstName $firstname LastName $lastname PasswordSet no Uid $number Gid $number
That needs to be all on one line. Compare your script carefully with the one on Darrell's site and fix any errors.
That said, I've seen another one I like better. It's written in perl, and (among other things) assigns UIDs sequentially rather than randomly. Unfortunately, I don't remember where it is, but a search of the forums here should locate it.
-
Now, it's here:
http://www.mobilia.it/filippo/download/mitel/adduser.tgz