Koozali.org: home of the SME Server

Legacy Forums => General Discussion (Legacy) => Topic started by: Karl McElwain on June 17, 2002, 07:08:33 PM

Title: Adding Multiple Users
Post by: Karl McElwain on June 17, 2002, 07:08:33 PM
Okay I've made the script and the import file....I'm in the correct folder /root

I've logged in as root....and verified the files are there.  But I'm getting an error when I try to run it

bash:  e-smith-add-user.sh: command not found

anybody have any ideas?

Thanks
Title: Re: Adding Multiple Users
Post by: Kees Vonk on June 17, 2002, 07:39:10 PM
Try

./e-smith-add-user.sh

Kees
Title: Re: Adding Multiple Users
Post by: Karl McElwain on June 17, 2002, 07:47:11 PM
well that did something....now I'm getting permission denied....I'm logged on as root so I really don't understand what could be going on.
Title: Re: Adding Multiple Users
Post by: Kees Vonk on June 17, 2002, 07:51:40 PM
Has you script got execute permissions?

Kees
Title: Re: Adding Multiple Users
Post by: Karl McElwain on June 17, 2002, 07:55:53 PM
I actually just thought about that and it wasn't set to be executable....what about the text file....what sort of permissions should it have?

Thanks I'm getting there.
Title: Re: Adding Multiple Users
Post by: Kees Vonk on June 17, 2002, 08:00:52 PM
As I don't know the script you are running I am not sure, but I presume that 644 with root:root ownership would do as you are running the script under root.

Kees
Title: Re: Adding Multiple Users
Post by: Karl McElwain on June 17, 2002, 08:08:51 PM
Success....I finally got it to run....i got the permissions all set and it started running the script.

Now the only problem is that the script is giving me errors....any idea on where I can get a clean script that works?

Oh by the way thank you soooo much.....I should have looked at the exec option but sometimes it takes somebody else to point out the obvious.

Karl
Title: Re: Adding Multiple Users
Post by: Kees Vonk on June 17, 2002, 08:22:22 PM
I might be able to help you if you can explain where you got the script from and what it is suppost to do.

Kees
Title: Re: Adding Multiple Users
Post by: Karl McElwain on June 17, 2002, 08:23:07 PM
here's what I got....line 31 something wrong with the "do" statement....already fixed the "fi" on line 23...changed it to "if"
---------------------
#!/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
if

# 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
Title: Re: Adding Multiple Users
Post by: Rich Lafferty on June 17, 2002, 08:29:04 PM
Karl McElwain wrote:
>
> here's what I got....line 31 something wrong with the "do"
> statement....already fixed the "fi" on line 23...changed it
> to "if"

That's not fixed. 'fi' closes 'if'.

  -Rich
Title: Re: Adding Multiple Users
Post by: robert on June 17, 2002, 08:31:03 PM
Actually, fi closes an if statement.
Title: Re: Adding Multiple Users
Post by: robert on June 17, 2002, 08:31:53 PM
You beat me, Rich.
Title: Re: Adding Multiple Users
Post by: Karl McElwain on June 17, 2002, 08:36:41 PM
okay then.....do either of you know why I'm getting a syntax error when it's "fi"

and the "do"?
Title: Re: Adding Multiple Users
Post by: Karl McElwain on June 17, 2002, 08:45:40 PM
hey guess what...I believe I figured it out.   When I used MC to edit the file is appears that there was some sort of character at the end of the line.  Once I did that it worked.  Thanks for everyone's help.