2 # /etc/profile: system-wide profile for the Bourne shell (sh(1)) and
3 # Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
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
51 #echo "/etc/profile ..."
55 # Initialize PATH variable
57 if [ -x /usr/libexec/path_helper ]; then
59 eval `/usr/libexec/path_helper -s`
61 PATH="/usr/local/bin:/usr/bin:/bin"
62 [ "$UID" -eq 0 ] && PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH"
64 # prepend optional directories to PATH ...
66 for d in /usr/pkg/bin /opt/*/bin; do
67 [ -d "$d" -o -h "$d" ] && path="$path$d:"
69 [ -n "$path" ] && PATH="$path$PATH"
70 if [ "$UID" -eq 0 ]; then
72 for d in /usr/pkg/sbin /opt/*/sbin; do
73 [ -d "$d" -o -h "$d" ] && path="$path$d:"
75 [ -n "$path" ] && PATH="$path$PATH"
77 # append optional directories to PATH ...
78 for d in /usr/bin/X11 /usr/games; do
79 [ -d "$d" -o -h "$d" ] && PATH="$PATH:$d"
81 # set PATH so it includes user's private executables
82 [ -d ~/Applications ] && PATH=~/Applications:"${PATH}"
83 [ -d ~/bin ] && PATH=~/bin:"${PATH}"
84 [ -d ~/sbin ] && PATH=~/sbin:"${PATH}"
86 # set MANPATH so it includes user's private man files
87 if [ -n "$MANPATH" ]; then
89 for d in /usr/pkg/share/man /usr/pkg/man /opt/*/share/man /opt/*/man; do
90 [ -d "$d" -o -h "$d" ] && path="$path$d:"
92 [ -n "$path" ] && MANPATH="$path$MANPATH"
94 [ -d ~/man ] && MANPATH=~/man:"${MANPATH}"
95 [ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}"
97 # set variable identifying the chroot you work in
98 [ -r /etc/debian_chroot ] && chroot_name=$(cat /etc/debian_chroot)
99 [ -r /etc/chroot_name ] && chroot_name=$(cat /etc/chroot_name)
101 # validate terminal definition
102 [ -z "$TERM" ] && eval `tset -s -Q`
104 # make sure $UID and $USER is set
105 [ -z "$UID" ] && UID=`id -u`
106 [ -z "$USER" ] && USER=`id -un`
109 # get my own hostname
113 # read profile additions
114 if [ -d /etc/profile.d ]; then
115 for f in /etc/profile.d/*; do
116 [ -r "$f" ] && . "$f"
120 # read local profile, if available
121 [ -r "/var/lib/${ME}/profile" ] && . /var/lib/${ME}/profile
126 # generic shell prompt
131 # bash-specific initialization
132 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] \
133 && source /etc/bash.bashrc
134 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bashrc ] \
135 && source /etc/bashrc
137 # ksh-specific initialization
138 [ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \
142 which quota >/dev/null 2>&1
143 [ $? -eq 0 ] && quota -q