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