]> arthur.barton.de Git - ConfigScripts.git/blob - sys/profile
Setup "PIP_DOWNLOAD_CACHE" using "XDG_CACHE_HOME"
[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=`echo "$LC_CTYPE" | cut -d. -f2- -s`
22 elif [ -n "$LANG" ]; then
23         LC_encoding=`echo "$LANG" | cut -d. -f2- -s`
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 unset 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 unset path
62 if [ "$LOGNAME" = "root" ]; then
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         unset path
70 fi
71 # append optional directories to PATH ...
72 for d in /usr/bin/X11 /usr/games /usr/share/php/bin; do
73         if [ -d "$d" -o -h "$d" ]; then
74                 [ -e "$d/.not_in_path" ] || PATH="$PATH:$d"
75         fi
76 done
77 unset d
78 # set PATH so it includes user's private executables
79 [ -d ~/Applications -a ! -e ~/Applications/.not_in_path ] \
80         && PATH=~/Applications:"${PATH}"
81 [ -d ~/bin -a ! -e ~/bin/.not_in_path ] \
82         && PATH=~/bin:"${PATH}"
83 [ -d ~/sbin -a ! -e ~/sbin/.not_in_path ] \
84         && PATH=~/sbin:"${PATH}"
85
86 # Setup MANPATH, if manpath(1) isn't available
87 if [ ! "$(type -t manpath 2>/dev/null)" ]; then
88         [ -z "$MANPATH" ] \
89                 && MANPATH="/usr/local/share/man:/usr/share/man:/usr/man"
90         path=""
91         for d in /usr/pkg/share/man /usr/pkg/man /opt/*/share/man /opt/*/man; do
92                 [ -d "$d" -o -h "$d" ] && path="$path$d:"
93         done
94         [ -n "$path" ] && MANPATH="$path$MANPATH"
95         [ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}"
96         [ -d ~/man ] && MANPATH=~/man:"${MANPATH}"
97         unset path d
98 fi
99
100 # set variable identifying the chroot you work in
101 [ -r /etc/debian_chroot ] && chroot_name=$(cat /etc/debian_chroot)
102 [ -r /etc/chroot_name ] && chroot_name=$(cat /etc/chroot_name)
103
104 # get my own hostname
105 [ -n "$HOSTNAME" ] || HOSTNAME=`hostname 2>/dev/null`
106 export HOSTNAME
107
108 # Setup some directories to use local storage (no NFS)
109 [ -d "/usr/local/home/$LOGNAME" ] \
110         || ( mkdir /usr/local/home; mkdir "/usr/local/home/$LOGNAME" ) >/dev/null 2>&1
111 [ -w "/usr/local/home/$LOGNAME" ] \
112         && export LOCAL_HOME="/usr/local/home/$LOGNAME" \
113         || export LOCAL_HOME="$HOME"
114 export XDG_CACHE_HOME="$LOCAL_HOME/.cache"
115
116 # Setup environment for ccache, if installed
117 type -t ccache 2>/dev/null && export CCACHE_DIR="$XDG_CACHE_HOME/ccache"
118
119 # Setup environment for Python "pip", if installed
120 if [ "$(type -t pip 2>/dev/null)" ]; then
121         export PIP_REQUIRE_VIRTUALENV=true
122         export PIP_DOWNLOAD_CACHE="$XDG_CACHE_HOME/pip"
123 fi
124
125 # Move Xauthority file to local storage, so that sudo et all work
126 if [ -z "$XAUTHORITY" -a -r ~/.Xauthority ]; then
127         cp ~/.Xauthority /tmp/Xauthority-$LOGNAME
128         chmod 600 /tmp/Xauthority-$LOGNAME
129         export XAUTHORITY="/tmp/Xauthority-$LOGNAME"
130 fi
131
132 # read profile additions
133 if [ -d /etc/profile.d -o -d /usr/local/etc/profile.d ]; then
134         for f in /etc/profile.d/* /usr/local/etc/profile.d/*; do
135                 [ -r "$f" ] || continue
136                 case "$f" in
137                         *.csh)
138                                 ;;
139                         *)
140                                 [ -e ~/.ConfigScripts.debug ] \
141                                         && echo " >> $f ..."
142                                 . "$f"
143                 esac
144         done
145         unset f
146 fi
147
148 # read local profile, if available
149 [ -r "/var/lib/${HOSTNAME}/profile" ] && . /var/lib/${HOSTNAME}/profile
150
151 # interactive shell?
152 [ "$PS1" ] || return
153
154 # validate terminal definition
155 type -t tset >/dev/null && eval `tset -s -Q`
156
157 # generic shell prompt
158 [ "$LOGNAME" = "root" ] \
159         && PS1="<$HOSTNAME> # " \
160         || PS1="<$HOSTNAME> \$ "
161
162 # Reminders (once every 60 minutes)
163 if [ -z `find ~/.last_reminder -mmin -60 2>/dev/null` ]; then
164         [ -e ~/.ConfigScripts.debug ] && echo " - Reminders ..."
165         if [ "$(type -t icalBuddy >/dev/null)" -a "$LOGNAME" != "root" ]; then
166                 # icalBuddy(1)
167                 case "$LANG" in
168                         *.UTF*) bul="•"; bul_imp="!"; sep="»"; ;;
169                         *)      bul="*"; bul_imp="!"; sep=">"; ;;
170                 esac
171                 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
172                         -nc -npn -iep "title,due" -stda \
173                         tasksDueBefore:today 2>/dev/null
174                 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
175                         -nc -npn -iep "title,datetime" \
176                         eventsToday+1 2>/dev/null
177                 [ $? -eq 0 ] && echo
178                 unset bul bul_imp sep
179         else
180                 # remind(1)
181                 if [ "$(type -t remind >/dev/null)" -a -r ~/.remind ]; then
182                         remind -h -g -t5 ~/.remind | \
183                                 grep -v '^Reminders for ' | grep -v '^$'
184                         [ $? -eq 0 ] && echo
185                 fi
186         fi
187         touch ~/.last_reminder
188 fi
189
190 # bash-specific initialization
191 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] \
192         && source /etc/bash.bashrc
193 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bashrc ] \
194         && source /etc/bashrc
195
196 # ksh-specific initialization
197 [ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \
198         && . /etc/ksh.kshrc
199
200 # Check filesystem quotas
201 mount 2>/dev/null | grep quota >/dev/null 2>&1
202 if [ $? -eq 0 ]; then
203         type -t quota >/dev/null && quota -q
204 fi
205
206 # -eof-