#!/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
|