summaryrefslogtreecommitdiff
path: root/profile
diff options
context:
space:
mode:
Diffstat (limited to 'profile')
-rw-r--r--profile58
1 files changed, 54 insertions, 4 deletions
diff --git a/profile b/profile
index d81777b..eddf6bd 100644
--- a/profile
+++ b/profile
@@ -1,15 +1,65 @@
# /etc/profile
-# System wide environment and startup programs
+# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
-HOSTNAME=`/bin/hostname`
+# It's NOT good idea to change this file unless you know what you
+# are doing. Much better way is to create custom.sh shell script in
+# /etc/profile.d/ to make custom changes to environment. This will
+# prevent need for merging in future updates.
+
+pathmunge () {
+ if ! echo $PATH | /bin/grep -qE "(^|:)$1($|:)" ; then
+ if [ "$2" = "after" ] ; then
+ PATH=$PATH:$1
+ else
+ PATH=$1:$PATH
+ fi
+ fi
+}
+
+
+if [ -x /usr/bin/id ]; then
+ if [ -z "$EUID" ]; then
+ # ksh workaround
+ EUID=`id -u`
+ UID=`id -ru`
+ fi
+ USER="`id -un`"
+ LOGNAME=$USER
+ MAIL="/var/spool/mail/$USER"
+fi
+
+# Path manipulation
+if [ "$EUID" = "0" ]; then
+ pathmunge /sbin
+ pathmunge /usr/sbin
+ pathmunge /usr/local/sbin
+else
+ pathmunge /usr/local/sbin after
+ pathmunge /usr/sbin after
+ pathmunge /sbin after
+fi
+
+HOSTNAME=`/bin/hostname 2>/dev/null`
HISTSIZE=1000
+if [ "$HISTCONTROL" = "ignorespace" ] ; then
+ export HISTCONTROL=ignoreboth
+else
+ export HISTCONTROL=ignoredups
+fi
-export PATH HOSTNAME HISTSIZE
+export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
- . $i
+ if [ "$PS1" ]; then
+ . $i
+ else
+ . $i >/dev/null 2>&1
+ fi
fi
done
+
+unset i
+unset pathmunge