OK, so I need to know how specify a command to run ONLY if two different items are answerd correctly.... here's what I mean...
========================================
echo -n "Do you need to create a new user for this Domain? [y/n]: "
read newuser
if test "$newuser" = "y"
then
echo -n "New Username: ";
read newusername;
else echo "No New users added, continuing with domain setup...";
fi
if test "$newuser" = "y"
then
echo -n "$newusername shall be added to what group? (leave blank for users): "
read grouptest
fi
if test "$grouptest" = ""
then
/usr/sbin/useradd -m -c '' -d /home/$newusername -s '/bin/bash' -G '' -e '' $newusername;
/usr/bin/chage -m -1 -M 99999 -W -1 $newusername;
passwd $newusername;
/usr/sbin/usermod -g users $newusername;
fi
######## Work in Progress ############
#if test "$newuser" = "y" 'and' "$grouptest" = "*"
# group=$grouptest #Redundant? no, I use $group later ;c)
# /usr/sbin/useradd -m -c '' -d /home/$newusername -s '/bin/bash' -G '' -e '' $newusername;
# /usr/bin/chage -m -1 -M 99999 -W -1 $newusername;
# passwd $newusername;
# groupadd $group
# /usr/sbin/usermod -g $group $newusername;
# echo "Continuing with domain setup...";
#fi
========================================
K, so ya see where I have "$grouptest" = ""... well for the 'if' statement which I hope to follow what you see above, I need to specify a couple things... One, anything other then 'nothing' entred (I had hoped "$grouptest" = "*" would work
)
as well as listening if both these tests pass... kind of like a....
if test "$newuser" = "y" 'and' "$grouptest" = "*"
I know what your thinking "Why don't you just make it an "else" or "elif" statement instead? Well, I'll tell you why...
Can't do 'elif' cause I dont know what they are going to enter as $grouptest
Can't do 'esle' because that will execute the rest of the commands to add a new group when the person didn't even want to add a new user!!! lol. It's probably something I've overlooked in the 'man bash' or online, but I can't seem to find the answer... Anyone l337 enough to help this n00b starving for information?