]> arthur.barton.de Git - ConfigScripts.git/blob - sys/profile
Make sure UID is always set
[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-2009 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 # Set locale if it is not set or doesn't contain a dot;
17 # but all system messages should still be in "native" ("C") language.
18 [ "$LANG" = "${LANG#*.}" -a "$LANG" != "C" ] \
19         && export LANG="${LANG:-de_DE}.ISO8859-1"
20 export LC_MESSAGES="C"
21
22 # Initialize PATH variable
23 export PATH MANPATH
24 if [ -x /usr/libexec/path_helper ]; then
25         PATH=""; MANPATH=""
26         eval `/usr/libexec/path_helper -s`
27 else
28         PATH="/usr/local/bin:/usr/bin:/bin"
29         [ "$UID" -eq 0 ] && PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH"
30 fi
31 # prepend optional directories to PATH ...
32 path=""
33 for d in /usr/pkg/bin /opt/*/bin; do
34         [ -d "$d" -o -h "$d" ] && path="$path$d:"
35 done
36 [ -n "$path" ] && PATH="$path$PATH"
37 if [ "$UID" -eq 0 ]; then
38         path=""
39         for d in /usr/pkg/sbin /opt/*/sbin; do
40                 [ -d "$d" -o -h "$d" ] && path="$path$d:"
41         done
42         [ -n "$path" ] && PATH="$path$PATH"
43 fi
44 # append optional directories to PATH ...
45 for d in /usr/bin/X11 /usr/games; do
46         [ -d "$d" -o -h "$d" ] && PATH="$PATH:$d"
47 done
48 # set PATH so it includes user's private executables
49 [ -d ~/Applications ] && PATH=~/Applications:"${PATH}"
50 [ -d ~/bin ] && PATH=~/bin:"${PATH}"
51 [ -d ~/sbin ] && PATH=~/sbin:"${PATH}"
52
53 # set MANPATH so it includes user's private man files
54 if [ -n "$MANPATH" ]; then
55         path=""
56         for d in /usr/pkg/share/man /usr/pkg/man /opt/*/share/man /opt/*/man; do
57                 [ -d "$d" -o -h "$d" ] && path="$path$d:"
58         done
59         [ -n "$path" ] && MANPATH="$path$MANPATH"
60 fi
61 [ -d ~/man ] && MANPATH=~/man:"${MANPATH}"
62 [ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}"
63
64 # set variable identifying the chroot you work in
65 [ -r /etc/debian_chroot ] && chroot_name=$(cat /etc/debian_chroot)
66 [ -r /etc/chroot_name ] && chroot_name=$(cat /etc/chroot_name)
67
68 # validate terminal definition
69 [ -z "$TERM" ] && eval `tset -s -Q`
70
71 # make sure $UID and $USER is set
72 [ -z "$UID" ] && UID=`id -u`
73 [ -z "$USER" ] && USER=`id -un`
74 export UID USER
75
76 # get my own hostname
77 ME=`hostname -s`
78 export ME
79
80 # Move Xauthority file to local storage, so that sudo et all work
81 if [ -z "$XAUTHORITY" -a -r ~/.Xauthority ]; then
82         cp ~/.Xauthority /tmp/Xauthority-$USER
83         chmod 600 /tmp/Xauthority-$USER
84         export XAUTHORITY="/tmp/Xauthority-$USER"
85 fi
86
87 # read profile additions
88 if [ -d /etc/profile.d ]; then
89         for f in /etc/profile.d/*; do
90                 [ -r "$f" ] || continue
91                 case "$f" in
92                         *.csh)
93                                 ;;
94                         *)
95                                 [ -e ~/.ConfigScripts.debug ] \
96                                         && echo " >> $f ..."
97                                 . "$f"
98                 esac
99         done
100 fi
101
102 # read local profile, if available
103 [ -r "/var/lib/${ME}/profile" ] && . /var/lib/${ME}/profile
104
105 # interactive shell?
106 [ "$PS1" ] || return
107
108 # generic shell prompt
109 [ "$UID" -eq 0 ] \
110         && PS1="<$ME> # " \
111         || PS1="<$ME> \$ "
112
113 # bash-specific initialization
114 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] \
115         && source /etc/bash.bashrc
116 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bashrc ] \
117         && source /etc/bashrc
118
119 # ksh-specific initialization
120 [ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \
121         && . /etc/ksh.kshrc
122
123 # Check filesystem quotas
124 which quota >/dev/null 2>&1
125 [ $? -eq 0 ] && quota -q
126
127 # -eof-