X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=config%2Fetc%2Fprofile;h=2d66685588f07b8aeacf77624beb1909532c159a;hb=9c7093a18bb01066834deb865cee976efbe3385d;hp=49e8678c594b30ea77a25c07e5224253d8583cb5;hpb=71e323840bc1da5dbaa3203b0e7051fea8f9b10f;p=ipfire-2.x.git diff --git a/config/etc/profile b/config/etc/profile index 49e8678c59..2d66685588 100644 --- a/config/etc/profile +++ b/config/etc/profile @@ -1,64 +1,78 @@ -# Begin /etc/profile -# Written for Beyond Linux From Scratch -# by James Robertson -# modifications by Dagmar d'Surreal +# /etc/profile -# System wide environment variables and startup programs. +# System wide environment and startup programs, for login setup +# Functions and aliases go in /etc/bashrc -# System wide aliases and functions should go in /etc/bashrc. Personal -# environment variables and startup programs should go into -# ~/.bash_profile. Personal aliases and functions should go into -# ~/.bashrc. +# It's NOT a good idea to change this file unless you know what you +# are doing. It's much better to create a custom.sh shell script in +# /etc/profile.d/ to make custom changes to your environment, as this +# will prevent the need for merging in future updates. -# Functions to help us manage paths. Second argument is the name of the -# path variable to be modified (default: PATH) -pathremove () { - local IFS=':' - local NEWPATH - local DIR - local PATHVARIABLE=${2:-PATH} - for DIR in ${!PATHVARIABLE} ; do - if [ "$DIR" != "$1" ] ; then - NEWPATH=${NEWPATH:+$NEWPATH:}$DIR - fi - done - export $PATHVARIABLE="$NEWPATH" +pathmunge () { + case ":${PATH}:" in + *:"$1":*) + ;; + *) + if [ "$2" = "after" ] ; then + PATH=$PATH:$1 + else + PATH=$1:$PATH + fi + esac } -pathprepend () { - pathremove $1 $2 - local PATHVARIABLE=${2:-PATH} - export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}" -} - -pathappend () { - pathremove $1 $2 - local PATHVARIABLE=${2:-PATH} - export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1" -} +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 -# Set the initial path -export PATH=/bin:/usr/bin +# 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 -if [ $EUID -eq 0 ] ; then - pathappend /sbin:/usr/sbin - unset HISTFILE +HOSTNAME=`/bin/hostname 2>/dev/null` +HISTSIZE=1000 +if [ "$HISTCONTROL" = "ignorespace" ] ; then + export HISTCONTROL=ignoreboth +else + export HISTCONTROL=ignoredups fi -# Setup some environment variables. -export HISTSIZE=1000 -export HISTIGNORE="&:[bf]g:exit" -#export PS1="[\u@\h \w]\\$ " -export PS1='\u@\h:\w\$ ' +export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL + +# By default, we want umask to get set. This sets it for login shell +# Current threshold for system reserved uid/gids is 200 +# You could check uidgid reservation validity in +# /usr/share/doc/setup-*/uidgid file +if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then + umask 002 +else + umask 022 +fi -for script in /etc/profile.d/*.sh ; do - if [ -r $script ] ; then - . $script +for i in /etc/profile.d/*.sh ; do + if [ -r "$i" ]; then + if [ "${-#*i}" != "$-" ]; then + . "$i" + else + . "$i" >/dev/null 2>&1 fi + fi done -# Now to clean up -unset pathremove pathprepend pathappend - -# End /etc/profile +unset i +unset pathmunge