Operating System - HP-UX
1832095 Members
3075 Online
110038 Solutions
New Discussion

Creating subdirectory in new user accounts

 
SOLVED
Go to solution
Clark Neville
New Member

Creating subdirectory in new user accounts

I would like to have a subdirectory automatically created for a new user when I create an account via SAM.
Is there any way to do this? Other OS's allow you to put a directory in /usr/skel because everything is copied from this directory to the user's home directory. I already have a script which creates the directory for existing user accounts. Thx
7 REPLIES 7
Jeff Schussele
Honored Contributor

Re: Creating subdirectory in new user accounts

Hi Clark,

Not 100% sure of exactly what you want, but in SAM there a dropdown from the Users page called Task Customization. And in there you can run commands, scripts, whatever you want for pre/post adds/removes of users.
The help button will tell you how SAM passes parms to any command you run.
Should do the trick for you I'd think.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Jeff Schussele
Honored Contributor

Re: Creating subdirectory in new user accounts

I should clarify that the Task Customization is in the Actions dropdown on the Users page.

Cheers,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Steven E. Protter
Exalted Contributor

Re: Creating subdirectory in new user accounts

I've just run a test on an 11i v1 system and found the same results. Actually I was rather surprised by the results.

I would think there might be patch for this.

If its however normal behavior:

The script that creates the user can be modified to mkdir the subdirectory and copy the files you want from /etc/skel

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Clark Neville
New Member

Re: Creating subdirectory in new user accounts

Thanks Jeff. I did see this "task customization" option but I could not figure how to get it to work. What I wanted to do was create a user account and automatically create a log directory in the new users home directory. There would be a /home/users/username/log directory for each new user.
Clark Neville
New Member

Re: Creating subdirectory in new user accounts

Thanks Steven. Can you explain further when you wrote "the script that adds the user can be modified? What script? I had noticed that when I put a new file in the /etc/skel directory, that file gets copied to the new user's home directory and a chown is done. But this behavior was not the case for a directory that I put in /etc/skel.
Jeff Schussele
Honored Contributor
Solution

Re: Creating subdirectory in new user accounts

Hi (again) Clark,

Take a look at the following file
/usr/sam/lib/ct_adduser.ex
Now create a root _only_ owned & executable file - preferably in root's home dir - usually /root. MUST only be owned & excutable by root or SAM will not run it
Insert the for/do/done loop at the top of the example file into this file & then add the following past it
/sbin/mkdir $home_dir/log
/sbin/chown $login_name:$group $home_dir/log
/sbin/chmod 644 $home_dir/log

Those example files show how to parse the output of the useradd / userdel commands that SAM executes.

Now just set proper ownership/perms on this script & enter the full path to the script in the Commands to Run After AAdding Users box & you're good to go.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Clark Neville
New Member

Re: Creating subdirectory in new user accounts

Perfect Jeff!! I have attached my customized script which is used by SAM. I created a /scripts directory at top level and put my script there. It works perfectly. I should mention again that if you put a file out in /etc/skel, SAM will copy this file and do a chown on it for the new user, but I needed a directory for Oracle to use in the user's home directory.
Thanks!!