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