Gentoo Archives: gentoo-dev

From: Duncan <1i5t5.duncan@×××.net>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Re: /etc/profile.d/
Date: Sun, 17 Jul 2005 11:38:53
Message-Id: pan.2005.07.17.11.35.08.220986@cox.net
In Reply to: Re: [gentoo-dev] /etc/profile.d/ by Herbert Fischer
1 Herbert Fischer posted <9f90e8bf050716181320b06312@××××××××××.com>,
2 excerpted below, on Sat, 16 Jul 2005 22:13:19 -0300:
3
4 > All scripts created by Gentoo emerges have some header signature (sort of
5 > cvs information), am I right?
6 >
7 > If so, some sort of checking script can detect Gentoo signed files on
8 > /etc/profile.d and just ignore them when scanning profile.d for user
9 > scripts.
10
11 [Just picked a post in the thread to reply to...]
12
13 Here's the solution I use here.
14
15 1. My /etc/profile, as well as all user ~/.bashrc files (that is, my
16 personal user, and root, and I'd setup skel for it too, if my system was a
17 multiple human user system), consist almost /entirely/ of one single
18 conditional execution. Note that I do *NOT* use the standard Gentoo
19 /etc/profile or /etc/bash/bashrc scripts.
20
21 # Source global definitions
22 if [ -f /etc/jedbashrc ]; then
23 . /etc/jedbashrc
24 fi
25
26 The jed is my initials. The idea is a namespace pollution guard -- I
27 don't have to worry about some package installing /etc/jedbashrc (and if
28 some package ever does, that's what portage's CONFIG_PROTECT is there for
29 =8^).
30
31 2. cat /etc/jedbashrc
32
33 # REMINDER: This is sourced by all bash shells on startup,
34 # including some such as scp and rcp that can't tolerate any output.
35
36 for i in /etc/profile.d/*; do
37 if [ $i = ${i%\~} -a $i = ${i%.bak} -a $i = ${i#.} -a $i = ${i%.csh} ]; then
38 . $i
39 fi
40 done
41
42 This runs all the scripts in /etc/profile.d EXCEPT backup files (*.back
43 and *~), hidden files (.*), and the csh scripts (*.csh). That's the
44 ENTIRE jedbashrc.
45
46 3. ls -1 /etc/profile.d
47
48 000profile.env.jed.sh
49 000user.jed.sh
50 010path.jed.sh
51 alias.jed.sh
52 bash-completion*
53 bash-hist.jed.sh
54 buildflags.jed.sh
55 editor.jed.sh
56 inputrc.jed.sh
57 noclobber.jed.sh
58 prompt.jed.sh
59 umask.jed.sh
60 xprint.sh*
61
62 bash-completion and xprint.sh, the portage installed scripts get executed
63 along with the others. Again with the namespace pollution prevention
64 thing -- the other scripts are mine and clearly marked as such.
65
66 Most of these substitute for functionality in the Gentoo default
67 /etc/profile and ~/.bashrc files, but many of them are customized for my
68 own purposes. (Among other things, I setup my path so the
69 /usr/local/(s)bin versions come first, thus making it dead simply to
70 substitute my own commands or wrapper scripts for Gentoo system defaults.)
71 Each task is modularized into its own file, the easier to maintain.
72
73 The 0xx scripts must be done first, as the others use stuff they setup.
74 The 000user script sets up $USER, used by 010path, which in turn allows
75 the other scripts to invoke commands without the absolute path. Other
76 than that, there's no specific order needed, so the straight names suffice.
77
78 ...
79
80 The only hassle I have with this system, is that every time Gentoo updates
81 bash, I have to scan the new /etc/bash/bashrc and /etc/profile files, to
82 see if there's any serious changes in functionality I need to match with
83 new /etc/profile.d modules, or changes to existing modules. However,
84 that's really only the same sort of thing a responsible sysadmin is always
85 doing, with updates to /etc, regardless of the package. Because my
86 config is all non-default files, I don't have to worry about them being
87 overwritten. The worst that could happen would be that my non-default
88 /etc/profile, simply a hook into my own config, would be overwritten by
89 the default. That's simple enough to fix, if so, because there's only the
90 single (tested) command in my version, easy enough to create from scratch
91 if I fat-finger things and overwrite it.
92
93 --
94 Duncan - List replies preferred. No HTML msgs.
95 "Every nonfree program has a lord, a master --
96 and if you use the program, he is your master." Richard Stallman in
97 http://www.linuxdevcenter.com/pub/a/linux/2004/12/22/rms_interview.html
98
99
100 --
101 gentoo-dev@g.o mailing list