]> arthur.barton.de Git - ConfigScripts.git/blob - sys/profile
Include profiles in /usr/local/etc/profile.d as well as in /etc/profile.d
[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 # Written 2003-2012 by Alexander Barton (alex@barton.de)
5 #
6
7 [ -e ~/.ConfigScripts.debug ] && echo " >> /etc/profile ..."
8
9 PROFILEREAD="true"
10 export PROFILEREAD
11
12 # Make sure UID is set
13 [ -n "$UID" ] || UID=`id -u`
14 export UID
15
16 # Indicates LC_CTYPE an UTF-8 terminal?
17 [ -n "$LC_CTYPE" ] \
18         && LC_encoding="${LC_CTYPE#*.}" || LC_encoding="ISO8859-1"
19 # Set locale if it is not set or doesn't contain a dot:
20 [ "$LANG" = "${LANG#*.}" -a "$LANG" != "C" ] \
21         && export LANG="${LANG:-de_DE}.${LC_encoding}"
22 # All system messages should still be in "native" ("C") language for
23 # non-X11 sessions:
24 [ -z "$GDMSESSION" -a -z "$XDG_SESSION_COOKIE" ] \
25         && export LC_MESSAGES="C"
26 # Clean up ...
27 unset LC_CTYPE LC_encoding 2>/dev/null
28
29 # Initialize PATH variable
30 if [ -x /usr/libexec/path_helper ]; then
31         eval `/usr/libexec/path_helper -s \
32                 | sed "s|:/usr/local/bin||" | sed "s|:/usr/local/sbin||"`
33         [[ "$PATH" == *sbin* ]] \
34                 && PATH="/usr/local/bin:/usr/local/sbin:$PATH" \
35                 || PATH="/usr/local/bin:$PATH"
36 else
37         PATH="/usr/local/bin:/usr/bin:/bin"
38         [ "$UID" -eq 0 ] && PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH"
39         export PATH
40 fi
41 # prepend optional directories to PATH ...
42 path=""
43 for d in /Developer/usr/bin /usr/pkg/bin /usr/lib/ccache /opt/*/bin; do
44         [ -d "$d" -o -h "$d" ] && path="$path$d:"
45 done
46 [ -n "$path" ] && PATH="$path$PATH"
47 if [ "$UID" -eq 0 ]; then
48         path=""
49         for d in /usr/pkg/sbin /opt/*/sbin; do
50                 [ -d "$d" -o -h "$d" ] && path="$path$d:"
51         done
52         [ -n "$path" ] && PATH="$path$PATH"
53 fi
54 # append optional directories to PATH ...
55 for d in /usr/bin/X11 /usr/games /usr/share/php/bin; do
56         [ -d "$d" -o -h "$d" ] && PATH="$PATH:$d"
57 done
58 # set PATH so it includes user's private executables
59 [ -d ~/Applications ] && PATH=~/Applications:"${PATH}"
60 [ -d ~/bin ] && PATH=~/bin:"${PATH}"
61 [ -d ~/sbin ] && PATH=~/sbin:"${PATH}"
62
63 # Setup MANPATH, if manpath(1) isn't available
64 if [ ! "$(type manpath 2>/dev/null)" ]; then
65         [ -z "$MANPATH" ] \
66                 && MANPATH="/usr/local/share/man:/usr/share/man:/usr/man"
67         path=""
68         for d in /usr/pkg/share/man /usr/pkg/man /opt/*/share/man /opt/*/man; do
69                 [ -d "$d" -o -h "$d" ] && path="$path$d:"
70         done
71         [ -n "$path" ] && MANPATH="$path$MANPATH"
72         [ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}"
73         [ -d ~/man ] && MANPATH=~/man:"${MANPATH}"
74 fi
75
76 # set variable identifying the chroot you work in
77 [ -r /etc/debian_chroot ] && chroot_name=$(cat /etc/debian_chroot)
78 [ -r /etc/chroot_name ] && chroot_name=$(cat /etc/chroot_name)
79
80 # validate terminal definition
81 [ -z "$TERM" ] && eval `tset -s -Q`
82
83 # make sure $UID and $USER is set
84 [ -z "$UID" ] && UID=`id -u`
85 [ -z "$USER" ] && USER=`id -un`
86 export UID USER
87
88 # get my own hostname
89 ME=`hostname 2>/dev/null`
90 export ME
91
92 # Move Xauthority file to local storage, so that sudo et all work
93 if [ -z "$XAUTHORITY" -a -r ~/.Xauthority ]; then
94         cp ~/.Xauthority /tmp/Xauthority-$USER
95         chmod 600 /tmp/Xauthority-$USER
96         export XAUTHORITY="/tmp/Xauthority-$USER"
97 fi
98
99 # read profile additions
100 if [ -d /etc/profile.d -o -d /usr/local/etc/profile.d ]; then
101         for f in /etc/profile.d/* /usr/local/etc/profile.d/*; do
102                 [ -r "$f" ] || continue
103                 case "$f" in
104                         *.csh)
105                                 ;;
106                         *)
107                                 [ -e ~/.ConfigScripts.debug ] \
108                                         && echo " >> $f ..."
109                                 . "$f"
110                 esac
111         done
112 fi
113
114 # read local profile, if available
115 [ -r "/var/lib/${ME}/profile" ] && . /var/lib/${ME}/profile
116
117 # Setup some directories to use local storage (no NFS)
118 [ -d "/usr/local/home/$USER" ] \
119         || mkdir -p "/usr/local/home/$USER" >/dev/null 2>&1
120 if [ -w "/usr/local/home/$USER" ]; then
121         export LOCAL_HOME="/usr/local/home/$USER"
122         export CCACHE_DIR="$LOCAL_HOME/.ccache"
123         export XDG_CACHE_HOME="$LOCAL_HOME/.cache"
124 fi
125
126 # interactive shell?
127 [ "$PS1" ] || return
128
129 # generic shell prompt
130 [ "$UID" -eq 0 ] \
131         && PS1="<$ME> # " \
132         || PS1="<$ME> \$ "
133
134 # icalBuddy(1)
135 type -p icalBuddy >/dev/null 2>&1
136 if [ $? -eq 0 -a "$UID" -ne 0 ]; then
137         case "$LANG" in
138                 *.UTF*) BUL="•"; SEP="»"; ;;
139                 *)      BUL="*"; SEP=">"; ;;
140         esac
141         icalBuddy -f -n -npn -nc -b " $BUL " -ps "/ $SEP /" -eep "url,notes" \
142                 eventsToday+1 | grep "$BUL"
143         [ $? -eq 0 ] && echo
144 else
145         # remind(1)
146         type -p remind >/dev/null 2>&1
147         if [ $? -eq 0 -a -r ~/.remind ]; then
148                 remind -h -g -t5 ~/.remind | \
149                         grep -v '^Reminders for ' | grep -v '^$'
150                 [ $? -eq 0 ] && echo
151         fi
152 fi
153
154 # bash-specific initialization
155 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] \
156         && source /etc/bash.bashrc
157 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bashrc ] \
158         && source /etc/bashrc
159
160 # ksh-specific initialization
161 [ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \
162         && . /etc/ksh.kshrc
163
164 # Check filesystem quotas
165 mount 2>/dev/null | grep quota >/dev/null 2>&1
166 if [ $? -eq 0 ]; then
167         which quota >/dev/null 2>&1
168         [ $? -eq 0 ] && quota -q
169 fi
170
171 # -eof-