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