]> arthur.barton.de Git - ConfigScripts.git/blob - sys/profile
Fix last commit: incorrect bash syntax :-/
[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 else
33         PATH="/usr/local/bin:/usr/bin:/bin"
34         [ "$UID" -eq 0 ] && PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH"
35         export PATH
36 fi
37 # prepend optional directories to PATH ...
38 path=""
39 for d in /Developer/usr/bin /usr/pkg/bin /usr/lib/ccache /opt/*/bin; do
40         [ -d "$d" -o -h "$d" ] && path="$path$d:"
41 done
42 [ -n "$path" ] && PATH="$path$PATH"
43 if [ "$UID" -eq 0 ]; then
44         path=""
45         for d in /usr/pkg/sbin /opt/*/sbin; do
46                 [ -d "$d" -o -h "$d" ] && path="$path$d:"
47         done
48         [ -n "$path" ] && PATH="$path$PATH"
49 fi
50 # append optional directories to PATH ...
51 for d in /usr/bin/X11 /usr/games; do
52         [ -d "$d" -o -h "$d" ] && PATH="$PATH:$d"
53 done
54 # set PATH so it includes user's private executables
55 [ -d ~/Applications ] && PATH=~/Applications:"${PATH}"
56 [ -d ~/bin ] && PATH=~/bin:"${PATH}"
57 [ -d ~/sbin ] && PATH=~/sbin:"${PATH}"
58
59 # Setup MANPATH, if manpath(1) isn't available
60 if [ ! "$(type manpath 2>/dev/null)" ]; then
61         [ -z "$MANPATH" ] \
62                 && MANPATH="/usr/local/share/man:/usr/share/man:/usr/man"
63         path=""
64         for d in /usr/pkg/share/man /usr/pkg/man /opt/*/share/man /opt/*/man; do
65                 [ -d "$d" -o -h "$d" ] && path="$path$d:"
66         done
67         [ -n "$path" ] && MANPATH="$path$MANPATH"
68         [ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}"
69         [ -d ~/man ] && MANPATH=~/man:"${MANPATH}"
70 fi
71
72 # set variable identifying the chroot you work in
73 [ -r /etc/debian_chroot ] && chroot_name=$(cat /etc/debian_chroot)
74 [ -r /etc/chroot_name ] && chroot_name=$(cat /etc/chroot_name)
75
76 # validate terminal definition
77 [ -z "$TERM" ] && eval `tset -s -Q`
78
79 # make sure $UID and $USER is set
80 [ -z "$UID" ] && UID=`id -u`
81 [ -z "$USER" ] && USER=`id -un`
82 export UID USER
83
84 # get my own hostname
85 ME=`hostname 2>/dev/null`
86 export ME
87
88 # Move Xauthority file to local storage, so that sudo et all work
89 if [ -z "$XAUTHORITY" -a -r ~/.Xauthority ]; then
90         cp ~/.Xauthority /tmp/Xauthority-$USER
91         chmod 600 /tmp/Xauthority-$USER
92         export XAUTHORITY="/tmp/Xauthority-$USER"
93 fi
94
95 # read profile additions
96 if [ -d /etc/profile.d ]; then
97         for f in /etc/profile.d/*; do
98                 [ -r "$f" ] || continue
99                 case "$f" in
100                         *.csh)
101                                 ;;
102                         *)
103                                 [ -e ~/.ConfigScripts.debug ] \
104                                         && echo " >> $f ..."
105                                 . "$f"
106                 esac
107         done
108 fi
109
110 # read local profile, if available
111 [ -r "/var/lib/${ME}/profile" ] && . /var/lib/${ME}/profile
112
113 # Setup some directories to use local storage (no NFS)
114 [ -d "/usr/local/home/$USER" ] \
115         || mkdir -p "/usr/local/home/$USER" >/dev/null 2>&1
116 if [ -w "/usr/local/home/$USER" ]; then
117         export LOCAL_HOME="/usr/local/home/$USER"
118         export CCACHE_DIR="$LOCAL_HOME/.ccache"
119         export XDG_CACHE_HOME="$LOCAL_HOME/.cache"
120 fi
121
122 # interactive shell?
123 [ "$PS1" ] || return
124
125 # generic shell prompt
126 [ "$UID" -eq 0 ] \
127         && PS1="<$ME> # " \
128         || PS1="<$ME> \$ "
129
130 # icalBuddy(1)
131 type -p icalBuddy >/dev/null 2>&1
132 if [ $? -eq 0 -a "$UID" -ne 0 ]; then
133         case "$LANG" in
134                 *.UTF*) BUL="•"; SEP="»"; ;;
135                 *)      BUL="*"; SEP=">"; ;;
136         esac
137         icalBuddy -f -n -npn -nc -b " $BUL " -ps "/ $SEP /" -eep "url,notes" \
138                 eventsToday+1 | grep "$BUL"
139         [ $? -eq 0 ] && echo
140 else
141         # remind(1)
142         type -p remind >/dev/null 2>&1
143         if [ $? -eq 0 -a -r ~/.remind ]; then
144                 remind -h -g -t5 .remind | grep "^[0-9]"
145                 [ $? -eq 0 ] && echo
146         fi
147 fi
148
149 # bash-specific initialization
150 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] \
151         && source /etc/bash.bashrc
152 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bashrc ] \
153         && source /etc/bashrc
154
155 # ksh-specific initialization
156 [ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \
157         && . /etc/ksh.kshrc
158
159 # Check filesystem quotas
160 mount 2>/dev/null | grep quota >/dev/null 2>&1
161 if [ $? -eq 0 ]; then
162         which quota >/dev/null 2>&1
163         [ $? -eq 0 ] && quota -q
164 fi
165
166 # -eof-