LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   adduser apache (https://www.linuxquestions.org/questions/linux-general-1/adduser-apache-101453/)

vipa5000 10-07-2003 09:55 PM

adduser apache
 
hey, what i want to do is when i use adduser username i want it to create a apache dir as well like /home/username/public_html, /home/username/public_html/cgi-bin and /home/username/perl is this possible at all im using mandrake

DavidPhillips 10-07-2003 10:24 PM

sure it's possible, I would make a script that you can run that will do it


#/bin/bash
adduser $1
mkdir -p /home/$1/public_html/cgi_bin /home/$1/perl
chown -R $1.$1 /home/$1/public_html /home/$1/perl





run like this..

scriptname username

vipa5000 10-07-2003 10:28 PM

Quote:

Originally posted by DavidPhillips
sure it's possible, I would make a script that you can run that will do it


#/bin/bash
adduser $1
mkdir -p /home/$1/public_html/cgi_bin /home/$1/perl
chown -R $1.$1 /home/$1/public_html /home/$1/perl





run like this..

scriptname username

thats what i was thinking but i was wondering if theirs any file u can put those in instead

DavidPhillips 10-07-2003 10:35 PM

Not sure what you mean, if you want to just type adduser username and have it happen there is a way to do that, otherwise I would make a new file in /usr/sbin/

anyway here it is

/sbin/adduser

#/bin/bash
/usr/sbin/adduser $1
mkdir -p /home/$1/public_html/cgi_bin /home/$1/perl
chown -R $1.$1 /home/$1/public_html /home/$1/perl



normally the path statement will have /sbin before /usr/sbin

so by running adduser the script file in /sbin will run instead of /usr/sbin/adduser

you will never know the difference.

vipa5000 10-07-2003 10:40 PM

thank you

DavidPhillips 10-07-2003 10:42 PM

There is one thing, if you plan to use any args to adduser then you will need to provide for that

it can be done like this, someone that knows bash better than I could improve this


/usr/sbin/adduser $2 $3 $4 $5 $6 $7 $1


then you could run like this

adduser username -c "Some comment" -p passwd


or whatever, you just need to have enough variables to do it

Like I said this is a crude way to do it.


One other idea would be to use /etc/skel which in this case may be the best solution

DavidPhillips 10-07-2003 10:44 PM

just add the folders to /etc/skel and they will be created when a newuser is added,

I should have thought of that before

vipa5000 10-07-2003 10:56 PM

Quote:

Originally posted by DavidPhillips
just add the folders to /etc/skel and they will be created when a newuser is added,

I should have thought of that before

yah thats exactly what i was looking for thanks

DavidPhillips 10-07-2003 11:01 PM

sometimes the little simple things get missed.

LOL


All times are GMT -5. The time now is 01:56 AM.