Operating System - HP-UX
1748142 Members
3646 Online
108758 Solutions
New Discussion юеВ

Re: custom .profile for members of a group

 
SOLVED
Go to solution
Jeff Zabel
Occasional Advisor

custom .profile for members of a group

I know this has to be simple, but I just can't figure it out. :O) What I would like to see happen is whenever a user is created with a certain template (group membership would be fine also) that a custom .profile be inserted in the users home directory. How would I go about scripting such a task? Thanks in advance.
9 REPLIES 9
Michael Tully
Honored Contributor

Re: custom .profile for members of a group

You can use the default profile in /etc/skel/.profile and modify it accordingly.

More information can found in the profile man page

# man profile
Anyone for a Mutiny ?
T G Manikandan
Honored Contributor

Re: custom .profile for members of a group

Whenever you create a user(using useradd),
not sure about SAM

the files .profile,.login,.cshrc are copied from the /etc/skel directory to the user's login directory.

So if you like to use a common template to all the users you can modify the .profile file existing here in this directory so that whenever users are created automatically this .profile is copied to the user's home directory.

If you are planning to execute something for all the users before they login then you can go with this option like

Making the entries in the /etc/profile file(for sh and ksh) and /etc/csh.login file (for csh)
These files will be executed before the local initialization files before the user logs in.


Thanks
Michael Tully
Honored Contributor

Re: custom .profile for members of a group

'SAM' has a tempate that can be created. You can also use 'useradd' to use a designated .profile set. The man page mentions this information. The -k options is used.

e.g.

# useradd -u 234 -g users -k /etc/skel1 -c "username" -s /usr/bin/ksh -d /home/username -m username
Anyone for a Mutiny ?
Tom Geudens
Honored Contributor

Re: custom .profile for members of a group

Hi,
We solved this "problem" as follows.
1. Modification in /etc/skel/.profile
# The following is added at the end ...
prof=prof`echo $HOME | cut -d '/' -f 3`
if [ -a /usr/local/bin/$prof ]
then
. /usr/local/bin/$prof
else
. /usr/local/bin/profrest
fi

2. For each "group" of users (having a /home/[group]/[user] homedirectory) we can have (or not) a /usr/local/bin/prof[group] specific file. If not, /usr/local/bin/profrest is used.

Hope this helps,
Tom

A life ? Cool ! Where can I download one of those from ?
Jeff Zabel
Occasional Advisor

Re: custom .profile for members of a group

I am already aware of etc/skel however, I do not want everyone to have this profile. Only people who belong to the group MEMO or their account were created with a template called MEMO. Every other account should have the original in etc/skel

Thanks
Jeff Zabel
Occasional Advisor

Re: custom .profile for members of a group

Sorry, one thing I forgot to mention is, if possible I would like to be able to do this all from SAM.

Thanks
Steve Faidley
Valued Contributor
Solution

Re: custom .profile for members of a group

Add the attached to your skel script and modify it as needed. When SAM moves the new .profile in place it will be all ready to do special things for your special groups.

If it ain't broke, let me have a look at it.
Steve Faidley
Valued Contributor

Re: custom .profile for members of a group

One more thing. If you don't want everyone to see what your doing then you could add a check for readable in the skel script and call a sub script to add your routines.

if [[ -r /app/special.profile ]]
then
. /app/special.profile
fi


make the file only readable by the group you want to use it.

chgrp special /app/special.profile
chmod 750 /app/special.profile


Hope this lines up ok on the forum!
If it ain't broke, let me have a look at it.
Jeff Zabel
Occasional Advisor

Re: custom .profile for members of a group

Steve,

I'm a little new to this. What do you mean by the skel script?

Regards