Welcome to WebmasterWorld Guest from 184.73.112.180

Forum Moderators: bakedjake

How do I do stuff on user creation?

   
8:47 am on May 4, 2010 (gmt 0)

5+ Year Member



I'm fed up of manually setting up NFS shares :(

How would I go about, on creating a user, creating some extra subdirectories in their home directory (is there a skeleton template somewhere) and adding some entries to /etc/fstab (I assume this will take some scripting to append the new entries to the end, but how do I trigger it?)
12:22 pm on May 4, 2010 (gmt 0)

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The skeleton directory is usually /etc/skel - adduser can copy the contents of this directory when creating a user (note: I only know about Debian/Ubuntu, don't know if this is the same for other distros). For the rest, I guess you could write a bash shell script to automate everything.
3:04 pm on May 4, 2010 (gmt 0)

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



/etc/skel is also the skeleton directory for the RedHat family Linux distributions. There is no integrated scripting in the adduser or useradd tools (on some systems adduser and useradd are different commands) where you can add the creation of mount points in the /etc/fstab directory. If you want to perform all actions in one pass, a container shell script is needed which calls the adduser program and some home made scripting to update the fstab file.
3:10 pm on May 4, 2010 (gmt 0)

5+ Year Member



Thanks encyclo - that's the easy part then, and I'm using Ubuntu (although I might be reverting to Kubuntu again as I keep finding that the preferences I want to set have been omitted in Ubuntu).

Now, I can probably cobble together a script to append lines to fstab, but can anybody tell me how I trigger it on user creation?
3:14 pm on May 4, 2010 (gmt 0)

5+ Year Member



Never mind, I've got a new approach. Write a script to handle the lot. Pass in username, uid and gid, then the script can create the group, add the user and do the appending to fstab... and I have to run even fewer commands to setup a user (which I need to do on the commandline anyway because easy-to-use *&^%* Ubuntu won't let me specify a uid (not that it always worked in previous versions of Kubuntu anyway!)).

<edit>Yay! I finally reached post 100!</yay>
<edit again>I must have been typing while you were posting lammert. Thanks for confirming what I suspected</edit_again>
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month