]> arthur.barton.de Git - ConfigScripts.git/blob - sys/profile
Enhance debug messages: print a line for each script.
[ConfigScripts.git] / sys / profile
1 #
2 # /etc/profile: system-wide profile for the Bourne shell (sh(1)) and
3 # Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
4 #
5 # 2008-08-07, alex@barton.de
6 #  - Added support for /etc/profile.d
7 #  - Added support for /etc/chroot_name
8 #  - Restructure PATH and MANPATH detecttion.
9 #  - Add ~/Applications to PATH.
10 #  - Add generic chroot name check.
11 #  - Check if debian_chroot is readable (insted of if it exists).
12 #  - Fix quota check, don't use full path name
13 # 2007-10-28, alex@barton.de
14 #  - Look for /usr/libexec/path_helper, used by Mac OS X 10.5
15 # 2007-04-05, alex@barton.de
16 #  - Check for and read /etc/bashrc as well, if /etc/bash.bashrc doesn't exist
17 # 2006-01-04, alex@barton.de
18 #  - Use "hostname -s" (not "--short") for compatibility to [Net]BSD.
19 #  - Added /usr/pkg/bin to optional PATH components.
20 # 2005-04-23, alex@Arthur.Ath.CX
21 #  - Removed umask, we do use the system default now.
22 # 2005-02-19, alex@Arthur.Ath.CX
23 #  - Removed export of CVS_RSH and MANWIDTH: use /etc/environment!
24 # 2005-02-04, alex@Arthur.Ath.CX
25 #  - Added export of CVS_RSH.
26 #  - Added export of MANWIDTH=80.
27 # 2005-01-23, alex@Arthur.Ath.CX
28 #  - Added check for quotas
29 # 2004-09-13, alex@Arthur.Ath.CX
30 #  - I made this script more generic, so that it is usabe for other systems
31 #    than Arthur as well: read in local profile from /var/lib/$ME/profile
32 #    after the initialization done in here.
33 #  - Changed shell prompt to generic version using "<" and ">".
34 #  - Make sure that $ME is set, even when not running interactive.
35 # 2004-08-11, alex@Arthur.Ath.CX
36 #  - Make sure that $USER is set.
37 #  - Always export $UID and $USER variables.
38 # 2004-07-30, alex@Arthur.Ath.CX
39 #  - Make sure $UID is set.
40 #  - Let ksh read in "/etc/ksh.kshrc".
41 # 2004-05-20, alex@Arthur.Ath.CX
42 #  - Added support for "$debian_chroot"
43 # 2004-02-16, alex@Arthur.Ath.CX
44 #  - Removed test for old home directory.
45 # 2004-02-02, alex@Arthur.Ath.CX
46 #  - Added scan for optional PATH elements.
47 # 2003-12-18, alex@Arthur.Ath.CX
48 #  - Initial version.
49 #
50
51 [ -e /tmp/ConfigDebug.$USER ] && echo " >> /etc/profile ..."
52
53 PROFILEREAD="true"
54 export PROFILEREAD
55
56 # Initialize PATH variable
57 export PATH MANPATH
58 if [ -x /usr/libexec/path_helper ]; then
59         PATH=""; MANPATH=""
60         eval `/usr/libexec/path_helper -s`
61 else
62         PATH="/usr/local/bin:/usr/bin:/bin"
63         [ "$UID" -eq 0 ] && PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH"
64 fi
65 # prepend optional directories to PATH ...
66 path=""
67 for d in /usr/pkg/bin /opt/*/bin; do
68         [ -d "$d" -o -h "$d" ] && path="$path$d:"
69 done
70 [ -n "$path" ] && PATH="$path$PATH"
71 if [ "$UID" -eq 0 ]; then
72         path=""
73         for d in /usr/pkg/sbin /opt/*/sbin; do
74                 [ -d "$d" -o -h "$d" ] && path="$path$d:"
75         done
76         [ -n "$path" ] && PATH="$path$PATH"
77 fi
78 # append optional directories to PATH ...
79 for d in /usr/bin/X11 /usr/games; do
80         [ -d "$d" -o -h "$d" ] && PATH="$PATH:$d"
81 done
82 # set PATH so it includes user's private executables
83 [ -d ~/Applications ] && PATH=~/Applications:"${PATH}"
84 [ -d ~/bin ] && PATH=~/bin:"${PATH}"
85 [ -d ~/sbin ] && PATH=~/sbin:"${PATH}"
86
87 # set MANPATH so it includes user's private man files
88 if [ -n "$MANPATH" ]; then
89         path=""
90         for d in /usr/pkg/share/man /usr/pkg/man /opt/*/share/man /opt/*/man; do
91                 [ -d "$d" -o -h "$d" ] && path="$path$d:"
92         done
93         [ -n "$path" ] && MANPATH="$path$MANPATH"
94 fi
95 [ -d ~/man ] && MANPATH=~/man:"${MANPATH}"
96 [ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}"
97
98 # set variable identifying the chroot you work in
99 [ -r /etc/debian_chroot ] && chroot_name=$(cat /etc/debian_chroot)
100 [ -r /etc/chroot_name ] && chroot_name=$(cat /etc/chroot_name)
101
102 # validate terminal definition
103 [ -z "$TERM" ] && eval `tset -s -Q`
104
105 # make sure $UID and $USER is set
106 [ -z "$UID" ] && UID=`id -u`
107 [ -z "$USER" ] && USER=`id -un`
108 export UID USER
109
110 # get my own hostname
111 ME=`hostname -s`
112 export ME
113
114 # read profile additions
115 if [ -d /etc/profile.d ]; then
116         for f in /etc/profile.d/*; do
117                 [ -r "$f" ] && . "$f"
118         done
119 fi
120
121 # read local profile, if available
122 [ -r "/var/lib/${ME}/profile" ] && . /var/lib/${ME}/profile
123
124 # interactive shell?
125 [ "$PS1" ] || return
126
127 # generic shell prompt
128 [ "$UID" -eq 0 ] \
129         && PS1="<$ME> # " \
130         || PS1="<$ME> \$ "
131
132 # bash-specific initialization
133 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] \
134         && source /etc/bash.bashrc
135 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bashrc ] \
136         && source /etc/bashrc
137
138 # ksh-specific initialization
139 [ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \
140         && . /etc/ksh.kshrc
141
142 # Check quotas
143 which quota >/dev/null 2>&1
144 [ $? -eq 0 ] && quota -q
145
146 # -eof-