I have tried launch this script
The script below will read in a text file containing user information and automatically create and set up e-smith user accounts. This is perfect for quickly adding multiple users to e-smith.
Simply cut and paste the entire script below (including the last line "done") into a file called e-smith-adduser.sh
Then create a text file called adduserlist.txt with the following format:
USERNAME1:FIRSTNAME1:LASTNAME1
USERNAME2:FIRSTNAME2:LASTNAME2
and place both the files in the /root directory.
To execute, login as root, change to the /root directory and enter (including the "."):
[root@e-smith /root]# . e-smith-adduser.sh
--------------------------------------------------------------------------------
#!/bin/sh
#
# USAGE:
#
# Create the file /root/adduserlist.txt in the following format:
#
# USERNAME1:FIRSTNAME1:LASTNAME1
# USERNAME2:FIRSTNAME2:LASTNAME2
#
# and so on...
#
# This script will create user accounts, mail accounts and pseudonyms for all the listed users in the /root/adduserlist.txt file.
#
# NOTE *By default usernames/passwords are set to the same value*
#
UFILE=/root/adduserlist.txt
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
username=echo $record | awk -F":" {'print $1'}
firstname=echo $record | awk -F":" {'print $2'}
lastname=echo $record | awk -F":" {'print $3'}
uid=echo $record | awk -F":" {'print $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 no Uid $number Gid $number
# ---------------
# Create Account
# ---------------
/sbin/e-smith/signal-event user-create $username
# ---------------
# Pause Script, bug reported by Jeffrey Smith
# ---------------
sleep 3
# ----------------
# Create Password
# -----------------------------------------------------
# (in this case the username and password are the same)
# eg: ( '$username', 'PASSWORD' );"
# -----------------------------------------------------
perl -e "use esmith::util; esmith::util::setUserPassword ( '$username', '$username' );"
# ---------------------------------
# Set value for password as created
# ---------------------------------
/sbin/e-smith/db accounts setprop $username 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 $username
/sbin/e-smith/signal-event pseudonym-create $firstname_$lastname $username
done
####################################################
.... but it seems not to work why it gives one series of errors. If it
works e-mail me.
Thank you