]> arthur.barton.de Git - ConfigScripts.git/blob - sys/profile
sys/profile: Update indentation of debug output
[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-2015 by Alexander Barton (alex@barton.de)
5 #
6
7 [ -e ~/.ConfigScripts.debug ] && echo " .. /etc/profile ..."
8
9 PROFILEREAD="true"
10 export PROFILEREAD
11
12 [ -e ~/.ConfigScripts.debug ] && echo " >> /etc/profile ..."
13
14 # Setup locale and encoding
15 if [ -e ~/.ConfigScripts.debug ]; then
16         echo "     - TERM=\"$TERM\""
17         echo "     - LANG=\"$LANG\""
18         echo "     - LC_CTYPE=\"$LC_CTYPE\""
19 fi
20 # Does LC_CTYPE or LANG indicate an UTF-8 terminal?
21 LC_encoding=""
22 if [ -n "$LC_CTYPE" ]; then
23         LC_encoding=`echo "$LC_CTYPE" | cut -d. -f2- -s`
24 elif [ -n "$LANG" ]; then
25         LC_encoding=`echo "$LANG" | cut -d. -f2- -s`
26 fi
27 if [ -z "$LC_encoding" ]; then
28         case "$TERM" in
29                 "xterm-"*)
30                         LC_encoding="UTF-8"; ;;
31                 *)
32                         LC_encoding="ISO8859-1"
33         esac
34 fi
35 [ -e ~/.ConfigScripts.debug ] && echo "     - LC_encoding=\"$LC_encoding\" (temp)"
36 # Set locale if it is not set or doesn't contain a dot:
37 [ "$LANG" = "${LANG#*.}" -a "$LANG" != "C" ] \
38         && export LANG="${LANG:-de_DE}.${LC_encoding}"
39 [ -e ~/.ConfigScripts.debug ] && echo "     - LANG=\"$LANG\" (new)"
40 # Clean up ...
41 unset LC_CTYPE LC_encoding 2>/dev/null
42
43 # Initialize PATH variable
44 if [ -x /usr/libexec/path_helper ]; then
45         eval `/usr/libexec/path_helper -s \
46                 | sed "s|:/usr/local/bin||" | sed "s|:/usr/local/sbin||"`
47         [[ "$PATH" == *sbin* ]] \
48                 && PATH="/usr/local/bin:/usr/local/sbin:$PATH" \
49                 || PATH="/usr/local/bin:$PATH"
50 else
51         PATH="/usr/local/bin:/usr/bin:/bin"
52         [ "$LOGNAME" = "root" ] && PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH"
53         export PATH
54 fi
55 # prepend optional directories to PATH ...
56 unset path
57 for d in \
58   /usr/local/opt/ccache/libexec \
59   /Developer/usr/bin \
60   /usr/pkg/bin \
61   /usr/ucb \
62   /usr/lib/ccache \
63   /opt/*/bin
64 do
65         if [ -d "$d" -o -h "$d" ]; then
66                 [ -e "$d/.not_in_path" ] || path="$path$d:"
67         fi
68 done
69 [ -n "$path" ] && PATH="$path$PATH"
70 unset path
71 if [ "$LOGNAME" = "root" ]; then
72         for d in \
73           /usr/pkg/sbin \
74           /opt/*/sbin
75         do
76                 if [ -d "$d" -o -h "$d" ]; then
77                         [ -e "$d/.not_in_path" ] || path="$path$d:"
78                 fi
79         done
80         [ -n "$path" ] && PATH="$path$PATH"
81         unset path
82 fi
83 # append optional directories to PATH ...
84 for d in \
85   /usr/bin/X11 \
86   /usr/games \
87   /usr/share/php/bin
88 do
89         if [ -d "$d" -o -h "$d" ]; then
90                 [ -e "$d/.not_in_path" ] || PATH="$PATH:$d"
91         fi
92 done
93 unset d
94 # set PATH so it includes user's private executables
95 [ -d ~/Applications -a ! -e ~/Applications/.not_in_path ] \
96         && PATH=~/Applications:"${PATH}"
97 [ -d ~/bin -a ! -e ~/bin/.not_in_path ] \
98         && PATH=~/bin:"${PATH}"
99 [ -d ~/sbin -a ! -e ~/sbin/.not_in_path ] \
100         && PATH=~/sbin:"${PATH}"
101
102 # Setup MANPATH, if manpath(1) isn't available
103 if [ ! "$(type -t manpath 2>/dev/null)" ]; then
104         [ -z "$MANPATH" ] \
105                 && MANPATH="/usr/local/share/man:/usr/share/man:/usr/man"
106         path=""
107         for d in \
108           /usr/pkg/share/man \
109           /usr/pkg/man \
110           /opt/*/share/man \
111           /opt/*/man
112         do
113                 [ -d "$d" -o -h "$d" ] && path="$path$d:"
114         done
115         [ -n "$path" ] && MANPATH="$path$MANPATH"
116         [ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}"
117         [ -d ~/man ] && MANPATH=~/man:"${MANPATH}"
118         unset path d
119 fi
120
121 # set variable identifying the chroot you work in
122 [ -r /etc/debian_chroot ] && chroot_name=$(cat /etc/debian_chroot)
123 [ -r /etc/chroot_name ] && chroot_name=$(cat /etc/chroot_name)
124
125 # get my own hostname
126 [ -n "$HOSTNAME" ] || HOSTNAME=`hostname 2>/dev/null`
127 export HOSTNAME
128
129 # Setup local home directory, when available
130 [ -d "/usr/local/home" -a ! -d "/usr/local/home/$LOGNAME" ] \
131         && mkdir "/usr/local/home/$LOGNAME" >/dev/null 2>&1
132 [ -w "/usr/local/home/$LOGNAME" ] \
133         && export LOCAL_HOME="/usr/local/home/$LOGNAME" \
134         || export LOCAL_HOME="$HOME"
135
136 # Source "~/.profile.user-1st", when available
137 [ -r ~/.profile.user-1st ] && . ~/.profile.user-1st
138
139 # Setup environment to use local storage (no NFS, if possible!)
140 export XDG_CACHE_HOME="$LOCAL_HOME/.cache"
141
142 # Setup environment for ccache, if installed
143 type -t ccache >/dev/null && export CCACHE_DIR="$XDG_CACHE_HOME/ccache"
144
145 # Setup environment for Python "pip", if installed
146 if [ "$(type -t pip 2>/dev/null)" ]; then
147         export PIP_REQUIRE_VIRTUALENV=true
148         export PIP_DOWNLOAD_CACHE="$XDG_CACHE_HOME/pip"
149 fi
150
151 # Move Xauthority file to local storage, so that sudo et all work
152 if [ -z "$XAUTHORITY" -a -r ~/.Xauthority ]; then
153         cp ~/.Xauthority /tmp/Xauthority-$LOGNAME
154         chmod 600 /tmp/Xauthority-$LOGNAME
155         export XAUTHORITY="/tmp/Xauthority-$LOGNAME"
156 fi
157
158 # read profile additions
159 if [ -d /etc/profile.d -o -d /usr/local/etc/profile.d ]; then
160         for f in \
161           /etc/profile.d/* \
162           /usr/local/etc/profile.d/*
163         do
164                 [ -r "$f" ] || continue
165                 case "$f" in
166                         *.csh)
167                                 ;;
168                         *)
169                                 [ -e ~/.ConfigScripts.debug ] \
170                                         && echo " >> $f ..."
171                                 . "$f"
172                 esac
173         done
174         unset f
175 fi
176
177 # read local profile, if available
178 [ -r "/var/lib/${HOSTNAME}/profile" ] && . /var/lib/${HOSTNAME}/profile
179
180 # interactive shell?
181 case "$-" in
182         *i*) ;;
183         *) return ;;
184 esac
185
186 # validate terminal definition
187 type -t tset >/dev/null && eval `tset -s -Q`
188
189 # generic shell prompt
190 [ "$LOGNAME" = "root" ] \
191         && PS1="<$HOSTNAME> # " \
192         || PS1="<$HOSTNAME> \$ "
193
194 # Reminders (once every 60 minutes)
195 if [ -z `find ~/.last_reminder -mmin -60 2>/dev/null` ]; then
196         [ -e ~/.ConfigScripts.debug ] && echo "     - Reminders ..."
197         if [ "$(type -t icalBuddy >/dev/null)" -a "$LOGNAME" != "root" ]; then
198                 # icalBuddy(1)
199                 case "$LANG" in
200                         *.UTF*) bul="•"; bul_imp="!"; sep="»"; ;;
201                         *)      bul="*"; bul_imp="!"; sep=">"; ;;
202                 esac
203                 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
204                         -nc -npn -iep "title,due" -stda \
205                         tasksDueBefore:today 2>/dev/null
206                 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
207                         -nc -npn -iep "title,datetime" \
208                         eventsToday+1 2>/dev/null
209                 [ $? -eq 0 ] && echo
210                 unset bul bul_imp sep
211         else
212                 # remind(1)
213                 if [ "$(type -t remind >/dev/null)" -a -r ~/.remind ]; then
214                         remind -h -g -t5 ~/.remind | \
215                                 grep -v '^Reminders for ' | grep -v '^$'
216                         [ $? -eq 0 ] && echo
217                 fi
218         fi
219         [ -w ~/ ] && touch ~/.last_reminder
220 fi
221
222 # bash-specific initialization
223 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] \
224         && source /etc/bash.bashrc
225 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bashrc ] \
226         && source /etc/bashrc
227
228 # ksh-specific initialization
229 [ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \
230         && . /etc/ksh.kshrc
231
232 # Check filesystem quotas
233 mount 2>/dev/null | grep quota >/dev/null 2>&1
234 if [ $? -eq 0 ]; then
235         type -t quota >/dev/null && quota -q
236 fi
237
238 # -eof-