You are not logged in.
Is there any way to run commands when a user logs in but before the bash profile is sourced?
For example, I have a user account with a home directory on /tmp. When the user logs in, the home directory might not exist so there will be no .bash_profile to source. I want to run a script to create the directory if necessary and copy some files into it. How can that be done?
I thought of putting something in /etc/profile or /etc/profile.d/, but I would like to run something before the user's shell and environment become active.
I can use /etc/rc.local to do what I want, but I would prefer a hook to ensure that everything is set right when the user logs in.
Any ideas?
*edit*
Solution
In my case, I found that I could write my own shell script and set it as a login shell. In the script, I can configure everything I need before launching the interactive shell, then clean up anything after it exits.
Last edited by Xyne (2011-12-10 19:34:07)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Take a look at 'man pam_exec'.
Maybe that is what you are looking for.
Offline
Thanks, dammannj. PAM could probably do what I need but I think I have found a simpler solution (see original post).
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline