1828926 Members
2907 Online
109986 Solutions
New Discussion

Login Script

 
Dineshkumar
Advisor

Login Script


Hi

I am too new to scripting ..

I would like to enable a script to achive

whenever a user login it should ask new or old user.

If its new user he should be able to create a account on the system

If he is old user he should login to system

Need of a script to run on FC5 (Fedora Core 5)

Dinesh
RHCE# 807303594707347
2 REPLIES 2
Alexander Chuzhoy
Honored Contributor

Re: Login Script

There's a problem with your desired setup.
A user must be root or the useradd/passwd commands must be setuid in order for regular user to create new accounts. You simply don't do it unless you wish to have a mess in your system.
Anyway if you want all your users to get the same message upon login - edit /etc/bashrc
append the following lines:

echo "Are you an old user?"
read answer
if [ $answer = "yes" ]; then
here comes your command
else
command to do if the user is old
fi
Alexander Chuzhoy
Honored Contributor

Re: Login Script

to achieve non-interactive user addition (that can be used in script):


useradd user_name; echo "user_password" |passwd --stdin;

echo "Are you an old user"
read answer
if [ $answer = "yes" ]; then
useradd user_name; echo "user_password" |passwd --stdin;
fi