#
# ROCK Linux: /etc/profile
#

# this is used for 'chroot . bin/sh -l' on a new
# system without mounted /dev and /proc

if [ -w / ] ; then
	if [ ! -e /dev/.devfsd ] ; then
		echo "Mounting /dev ..." ; mount none /dev -t devfs
	fi
	if [ ! -e /proc/self ] ; then
		echo "Mounting /proc ..." ; mount none /proc -t proc
	fi
fi

# set the PATH-variable

if [ -w / ] ; then
	PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
	for x in /usr/X11/sbin /usr/X11/bin /usr/games /usr/local/games \
	         /opt/*/sbin /opt/*/bin $HOME/sbin $HOME/bin
	do
		[ -d $x ] && export PATH="$PATH:$x"
	done
else
	PATH='/bin:/usr/bin:/usr/local/bin'
	for x in /usr/X11/bin /usr/games /usr/local/games /opt/*/bin $HOME/bin
	do
		[ -d $x ] && export PATH="$PATH:$x"
	done
fi
export PATH

# set the prompts for bash and ksh

if [ ".$BASH" != . ] ; then
	if [ "$UID" = 0 ]; then
	    export PS1="\[\e[1;31m\]\h:\w # \[\e[0m\]"
	else
            export PS1="\[\e[1;32m\]\u@\h:\w > \[\e[0m\]"
	fi
	export PS2='> ' ; export PS4='+ '
elif [ ".$KSH_VERSION" != . ] ; then
	[ -w / ] && PS1='$USER:$PWD# ' || PS1='$USER:$PWD$ '
	export PS2='> ' ; export PS4='+ '
fi

# set some enviroment-variables

if [ ".$SHELL" = "./bin/sh" ] ; then
	export "SHELL=/bin/bash"
fi

export EDITOR="vi"
export PAGER="less"
export BLOCKSIZE=K

# hack to have a vaild first path
# (so others can concat :/xyz without getting . into the search path)
export LD_LIBRARY_PATH=/lib

# set the MANPATH variable

MANPATH=/usr/share/man
for x in /usr/X11/man /usr/local/man /usr/local/share/man /opt/*/man
do [ -d $x ] && export MANPATH="$MANPATH:$x" ; done

# set the INFOPATH variable

INFOPATH=/usr/share/info
for x in /usr/X11/info /usr/local/info /usr/local/share/info /opt/*/info
do [ -d $x ] && export INFOPATH="$INFOPATH:$x" ; done

# set colors for ls
if [ -f ~/.dircolors ]; then
    eval `dircolors -b ~/.dircolors`
elif [ -f /etc/dircolors ]; then
    eval `dircolors -b /etc/dircolors`
fi

# some usefull aliases (only if this is an interactive shell)

if [ "$PS1" ] ; then
	alias cp='cp -i'
	alias mv='mv -i'
	alias rm='rm -i'
	alias md='mkdir'
	alias l="ls -al"
	alias -- +='pushd .'
	alias -- -='popd'
	alias ..='cd ..'
	alias ...='cd ../..'
	alias useradd='useradd -m'  # use /etc/skel
	
	if [ -w / ] ; then
		alias ls="ls --color=tty --show-control-chars -a"
	else
		alias ls="ls --color=tty --show-control-chars"
	fi

	alias which="type -p"
	alias rehash="hash -r"
fi

# include local profiles

for x in /etc/profile.d/* /etc/conf/profile ; do
	[ -f $x ] && . $x
done
unset x
