Herbert Fischer posted <[EMAIL PROTECTED]>,
excerpted below, on Sat, 16 Jul 2005 22:13:19 -0300:
> All scripts created by Gentoo emerges have some header signature (sort of
> cvs information), am I right?
>
> If so, some sort of checking script can detect Gentoo signed files on
> /etc/profile.d and just ignore them when scanning profile.d for user
> scripts.
[Just picked a post in the thread to reply to...]
Here's the solution I use here.
1. My /etc/profile, as well as all user ~/.bashrc files (that is, my
personal user, and root, and I'd setup skel for it too, if my system was a
multiple human user system), consist almost /entirely/ of one single
conditional execution. Note that I do *NOT* use the standard Gentoo
/etc/profile or /etc/bash/bashrc scripts.
# Source global definitions
if [ -f /etc/jedbashrc ]; then
. /etc/jedbashrc
fi
The jed is my initials. The idea is a namespace pollution guard -- I
don't have to worry about some package installing /etc/jedbashrc (and if
some package ever does, that's what portage's CONFIG_PROTECT is there for
=8^).
2. cat /etc/jedbashrc
# REMINDER: This is sourced by all bash shells on startup,
# including some such as scp and rcp that can't tolerate any output.
for i in /etc/profile.d/*; do
if [ $i = ${i%\~} -a $i = ${i%.bak} -a $i = ${i#.} -a $i = ${i%.csh} ]; then
. $i
fi
done
This runs all the scripts in /etc/profile.d EXCEPT backup files (*.back
and *~), hidden files (.*), and the csh scripts (*.csh). That's the
ENTIRE jedbashrc.
3. ls -1 /etc/profile.d
000profile.env.jed.sh
000user.jed.sh
010path.jed.sh
alias.jed.sh
bash-completion*
bash-hist.jed.sh
buildflags.jed.sh
editor.jed.sh
inputrc.jed.sh
noclobber.jed.sh
prompt.jed.sh
umask.jed.sh
xprint.sh*
bash-completion and xprint.sh, the portage installed scripts get executed
along with the others. Again with the namespace pollution prevention
thing -- the other scripts are mine and clearly marked as such.
Most of these substitute for functionality in the Gentoo default
/etc/profile and ~/.bashrc files, but many of them are customized for my
own purposes. (Among other things, I setup my path so the
/usr/local/(s)bin versions come first, thus making it dead simply to
substitute my own commands or wrapper scripts for Gentoo system defaults.)
Each task is modularized into its own file, the easier to maintain.
The 0xx scripts must be done first, as the others use stuff they setup.
The 000user script sets up $USER, used by 010path, which in turn allows
the other scripts to invoke commands without the absolute path. Other
than that, there's no specific order needed, so the straight names suffice.
...
The only hassle I have with this system, is that every time Gentoo updates
bash, I have to scan the new /etc/bash/bashrc and /etc/profile files, to
see if there's any serious changes in functionality I need to match with
new /etc/profile.d modules, or changes to existing modules. However,
that's really only the same sort of thing a responsible sysadmin is always
doing, with updates to /etc, regardless of the package. Because my
config is all non-default files, I don't have to worry about them being
overwritten. The worst that could happen would be that my non-default
/etc/profile, simply a hook into my own config, would be overwritten by
the default. That's simple enough to fix, if so, because there's only the
single (tested) command in my version, easy enough to create from scratch
if I fat-finger things and overwrite it.
--
Duncan - List replies preferred. No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master." Richard Stallman in
http://www.linuxdevcenter.com/pub/a/linux/2004/12/22/rms_interview.html
--
[email protected] mailing list