#!/bin/sh

Start()
{
	if ! grep ${PKG_NAME} /etc/profile >/dev/null
	then
		cat <<__EOF__ >>/etc/profile
if [ -t 1 ] ; then		# ${PKG_NAME} Hook
	for file in \$( ls ${PKG_ROOT}/etc/profile.d/ ) # ${PKG_NAME} Hook
	do # ${PKG_NAME} Hook
		full=${PKG_ROOT}/etc/profile.d/\$file # ${PKG_NAME} Hook
		[ -x \$full ] && . \$full # ${PKG_NAME} Hook
	done # ${PKG_NAME} Hook
	unset file # ${PKG_NAME} Hook
	unset full # ${PKG_NAME} Hook
fi # ${PKG_NAME} Hook
__EOF__
	fi
}


Stop()
{
	if grep ${PKG_NAME} /etc/profile >/dev/null
	then
		grep -v ${PKG_NAME} /etc/profile >/etc/profile.new
		mv /etc/profile.new /etc/profile
	fi
}

case $1 in
    start) 
	Start ;;
    stop)
	Stop ;;
esac

