Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-26-2002, 11:41 PM
|
#1
|
Member
Registered: Feb 2002
Location: India
Distribution: Slacky 12.1, XP
Posts: 992
Rep:
|
Running a shell script when a user is added.
Hi all
when ever a new user is added a shell script should be executed, which creates a directory in /var/www/html/<username>.
how do i do that?
thanks for any help.
regards
jayakrishnan
|
|
|
04-27-2002, 08:22 AM
|
#2
|
Member
Registered: Jan 2002
Location: Cheyenne Wyoming
Distribution: Debian/Raspbian/Mint
Posts: 717
Rep:
|
Take a look at the adduser script, you could change the script to make a users default home directory /var/www/html/<username> , if you edit adduser script i would suggest making a backup and nameing it a different name ie: adduser-html. And just use that for your www users.
|
|
|
04-27-2002, 08:40 AM
|
#3
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
adduser / useradd is a binary executable, not a script.
|
|
|
04-27-2002, 05:39 PM
|
#4
|
Member
Registered: Jan 2002
Location: Cheyenne Wyoming
Distribution: Debian/Raspbian/Mint
Posts: 717
Rep:
|
well, I did a more on adduser on my slackware box and it was a plain text script. It has references back to useradd and the passwd commands.
#!/bin/sh
# adduser script for use with shadow passwords and useradd command.
# by Hrvoje Dogan <hdogan@student.math.hr>, Dec 1995.
# Modified by Patrick Volkerding, Oct 1997, Mar 1999, May 2000.
echo
echo -n "Login name for new user []: "
read LOGIN
if [ -z "$LOGIN" ]; then
echo "Come on, man, you can't leave the login field empty..."
exit
fi
echo
echo -n "User id for $LOGIN [ defaults to next available]: "
read ID
GUID="-u $ID"
if [ -z "$ID" ]; then
GUID=""
fi
echo
echo -n "Initial group for $LOGIN [users]: "
read GID
if [ -z "$GID" ]; then
GID="users"
fi
GGID="-g $GID"
echo
echo "Additional groups for $LOGIN (seperated"
echo -n "with commas, no spaces) []: "
read AGID
GAGID="-G $AGID"
if [ -z "$AGID" ]; then
GAGID=""
fi
echo
echo -n "$LOGIN's home directory [/home/$LOGIN]: "
read HME
if [ -z "$HME" ]; then
HME="/home/$LOGIN"
fi
GHME="-d $HME"
echo
echo -n "$LOGIN's shell [/bin/bash]: "
read SHL
GSHL="-s $SHL"
if [ -z "$SHL" ]; then
GSHL="-s /bin/bash"
SHL="/bin/bash"
fi
echo
echo -n "$LOGIN's account expiry date (YYYY-MM-DD) []: "
read EXP
GEXP="-e $EXP"
if [ -z "$EXP" ]; then
GEXP=""
fi
echo
echo "OK, I'm about to make a new account. Here's what you entered so far:"
echo
echo New login name: $LOGIN
if [ -z "$GUID" ]; then
echo New UID: [Next available]
else
echo New UID: $UID
fi
if [ -z "$GGID" ]; then
echo Initial group: users
else
echo Initial group: $GID
fi
if [ -z "$GAGID" ]; then
echo Additional groups: [none]
else
echo Additional groups: $AGID
fi
if [ -z "$GHME" ]; then
echo Home directory: /home/$LOGIN
else
echo Home directory: $HME
fi
if [ -z "$GSHL" ]; then
echo Shell: /bin/bash
else
echo Shell: $SHL
fi
if [ -z "$GEXP" ]; then
echo Expiry date: [no expiration]
else
echo Expiry date: $EXP
fi
echo
echo "This is it... if you want to bail out, hit Control-C. Otherwise, press"
echo "ENTER to go ahead and make the account."
read FOO
echo
echo Making new account...
/usr/sbin/useradd $GHME -m $GEXP $GGID $GAGID $GSHL $GUID $LOGIN
if [ -d $HME ]; then
chmod 711 $HME
fi
echo
/usr/bin/chfn $LOGIN
echo
/usr/bin/passwd $LOGIN
echo "Done..."
Maybe its different in RH or Mandy, I dont have my RH box up right now.
Last edited by hanzerik; 04-27-2002 at 05:40 PM.
|
|
|
04-29-2002, 12:35 AM
|
#5
|
Member
Registered: Feb 2002
Location: India
Distribution: Slacky 12.1, XP
Posts: 992
Original Poster
Rep:
|
adduser is a binary file in RH.
Can anyone help?
|
|
|
04-29-2002, 02:55 AM
|
#6
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
well why can't you just run both commands in a shell script? it's not exactly difficult...
#!/bin/sh
useradd $*
mkdir /var/www/html/$1
i'd recommend just setting up your webserver properly tho, so you give users PROPER web locations in their /home dir. ( www.web.com/~jeff --> /home/jeff/public_html/)
|
|
|
All times are GMT -5. The time now is 06:41 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|