Script to create users on NIS master server

I would like to add a new user to a system using script, including building thehome directory of the user, copying its default config data, etc.For a standard Unix/Linux system, not Mac OS X.

There is something wrong with the script below. When I run it, it gives some errors. I am not good in scripting.

******************************************************************************

pwfile="/var/yp/control_files/passwd"

gfile="/etc/group"

hdir="/vol2/home"

if [ "$(whoami)" != "root" ] ; then

echo "Error: You must be root to run this command." >&2

exit 1

fi

echo "Add new user account to $(hostname)"

echo -n "login: "; read login

# adjust '5000' to match the top end of your user account namespace

# because some system accounts have uid's like 65535 and similar.

echo -n "uid: " ; read uid

#uid="$(awk -F: '{ if (big < $3 && $3 < 5000) big=$3 } END { print big + 1 }' $p

wfile)"

homedir=$hdir/$login

# we are giving each user their own group, so gid=uid

gid=10

echo -n "full name: " ; read fullname

shell=sh

echo "Setting up account $login for $fullname..."

echo ${login}:x:${uid}:${gid}:${fullname}:${homedir}:$shell >> $pwfile

#echo ${login}:*:11647:0:99999:7::: >> $shadowfile

echo "${login}:x:${gid}:$login" >> $gfile

mkdir $homedir

cp -R /etc/skel/.[a-zA-Z]* $homedir

chmod 755 $homedir

find $homedir -print | xargs chown ${login}:$login

# setting an initial password

#passwd $login

exit

***************************************************************************

[1724 byte] By [cplsga] at [2007-11-26 17:34:49]
# 1
"some errors" is no substitute for actually posting what errors you are getting.
Codename47a at 2007-7-9 0:02:49 > top of Java-index,General,Talk to the Sysop...