# This is the system-wide .profile file for Bourne-compatible shells. Do not
# edit this file. Instead put your own scripts with extension '.sh' into the
# directory '/etc/profile.d'.

PATH="/tools/bin:/usr/bin"

#
# Fix the path.
#
if [ "`id -u`" -eq 0 ] || [ -f "/etc/target" ]; then
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
else
    PATH="/usr/local/bin:/usr/bin"
fi

if [ -d "/tools" ]; then
    PATH="/tools/bin:/tools/sbin:$PATH"
fi

#
# Fix the prompt.
#
if [ -f "/etc/target" ]; then
    target_name=`cat /etc/target | grep '^TARGET_ID'      | cut -d'=' -f2`
    target_mach=`cat /etc/target | grep '^TARGET_MACHINE' | cut -d'=' -f2`

    if [ "`id -u`" -eq 0 ]; then
        PS1="\u@$target_name($target_mach):\w\# \[\e]2;\u@$target_name($target_mach):\w\a\]"
    else
        PS1="\u@$target_name($target_mach):\w\$ \[\e]2;\u@$target_name($target_mach):\w\a\]"
    fi

    unset target_name
    unset target_mach
else
    if [ "`id -u`" -eq 0 ]; then
        PS1='\u@\h:\w\# \[\e]2;\u@$target_name($target_mach):\w\a\]'
    else
        PS1='\u@\h:\w\$ \[\e]2;\u@$target_name($target_mach):\w\a\]'
    fi
fi

#
# Read in addtional configuration files.
#
if [ -d "/etc/profile.d" ]; then
  for script in /etc/profile.d/*.sh; do
    if [ -r "$script" ]; then
      . "$script"
    fi
  done
  unset script
fi

export PATH
