# /etc/profile: This file contains system-wide defaults used by
# all Bourne (and related) shells.

# Set the locale first
if [ -s /etc/locale.conf ]; then
	. /etc/locale.conf
	if [ -n "$LANG" ]; then
		export LANG
	else
		unset LANG
	fi
	if [ -n "$LANGUAGE" ]; then
		export LANGUAGE
	else
		unset LANGUAGE
	fi
	if [ -n "$LC_ADDRESS" ]; then
		export LC_ADDRESS
	else
		unset LC_ADDRESS
	fi
	if [ -n "$LC_COLLATE" ]; then
		export LC_COLLATE
	else
		unset LC_COLLATE
	fi
	if [ -n "$LC_CTYPE" ]; then
		export LC_CTYPE
	else
		unset LC_CTYPE
	fi
	if [ -n "$LC_IDENTIFICATION" ]; then
		export LC_IDENTIFICATION
	else
		unset LC_IDENTIFICATION
	fi
	if [ -n "$LC_MEASUREMENT" ]; then
		export LC_MEASUREMENT
	else
		unset LC_MEASUREMENT
	fi
	if [ -n "$LC_MESSAGES" ]; then
		export LC_MESSAGES
	else
		unset LC_MESSAGES
	fi
	if [ -n "$LC_MONETARY" ]; then
		export LC_MONETARY
	else
		unset LC_MONETARY
	fi
	if [ -n "$LC_NAME" ]; then
		export LC_NAME
	else
		unset LC_NAME
	fi
	if [ -n "$LC_NUMERIC" ]; then
		export LC_NUMERIC
	else
		unset LC_NUMERIC
	fi
	if [ -n "$LC_PAPER" ]; then
		export LC_PAPER
	else
		unset LC_PAPER
	fi
	if [ -n "$LC_TELEPHONE" ]; then
		export LC_TELEPHONE
	else
		unset LC_TELEPHONE
	fi
	if [ -n "$LC_TIME" ]; then
		export LC_TIME
	else
		unset LC_TIME
	fi
fi

# Set HOSTNAME if not already set.
if [ -s /etc/hostname -a -z "$HOSTNAME" ]; then
	HOSTNAME="$(cat /etc/hostname)"
fi
export HOSTNAME

# Set the default system PATH
PATH="/usr/local/bin:/usr/bin:/bin"

# For root users, ensure that all system binaries directories are in PATH.
if [ "$(id -u)" -eq 0 ]; then
	PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH"
fi
export PATH

# Set TERM if it's an invalid value.
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
	TERM="linux"
fi
export TERM

# Set a default shell prompt. It should look something like this:
#'`whoami`@`hostname`:`pwd`$ '
if [ "$SHELL" = "/bin/bash" ]; then
	PS1='\u@\h:\w\$ '
elif [ "$SHELL" = "/bin/zsh" ]; then
	PS1='%n@%m:%~%# '
else
	PS1='$(whoami)@$(hostname):$(pwd)'
	if [ "$(id -u)" -eq 0 ]; then
		PS1="${PS1}# "
	else
		PS1="${PS1}\$ "
	fi
fi
export PS1 PS2='> '

# Default umask.  A umask of 022 prevents new files from being created group
# and world writable.
umask 022

# export DISPLAY if it's set
if [ -n "$DISPLAY" ]; then
	export DISPLAY
fi

# Append any additional sh scripts found in /etc/profile.d
for i in /etc/profile.d/*.sh; do
	if [ -x "$i" ]; then
		. "$i"
	fi
done

# Unset local variables
unset i
