Well, a couple of things:
First, this error
Quote:
adduser: user greg exists
|
implies hat you've run the script before using "greg" as a test case and never removed him, or that greg is a legitimate user.
Second, the next sequence of errors can be explained if a basic assumption in your scipt fails. That is, you call
adduser, and your script assumes
adduser will create a home directory (/home/greg). What if it doesn't? If it doesn't, then your next command:
Quote:
cp /usrfiles/config /home/$1
|
would copy /usrfiles/config to a
file named /home/greg--not into a directory named /home/greg because the directory wasn't created.
That means the
cd fails, all the other ownership/permissions changing stuff also fail.
Third, your if-else statement needs a "fi" at the end:
Code:
# display info
if [ -d /home/$1 ]; then
echo "User $1 created with home directory of /home/$1"
else
echo "No user created"
fi
I would suggest using the standard tools for all this (that's what they are there for
)
Read the man page for
adduser (sometimes named
useradd) and read about the options, specifically -m and -p. The reason I suggest -p is because the password argument is expected to have already been passed through crypt. That is, if your script had worked, "asdfasdf" would be the
encrypted form of the password and not the text a user would type to login.