#! /bin/sh
#
#	Shell to begin execution of PortMaster command processor
#
#	We need the system architecture and the version of SunOS to
#	determine which executable to run.
#
PATH=/bin:/usr/bin:/usr/ucb:$PATH
#
#
#	Get full path of this shell script
#
DIR=`expr \
  ${0-.}'/' : '\(/\)[^/]*/$' \
  \| ${0-.}'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \
  \| .`
#
#
ARCH=""
if [ -f /bin/arch ]
then
	ARCH=`arch`
	FOUND_RELEASE=0
	for i in `cat /etc/motd`
	do
		if [ "$i" = "Release" ]
		then
			FOUND_RELEASE=1
		elif [ $FOUND_RELEASE -eq 1 -a "$SYSOS" = "" ]
		then
			SYSOS=`echo $i | awk '{printf("%.3s", $1)}'`
		fi
	done
fi
#
#
if [ "$ARCH" = "" ]
then
	ARCH=`uname -m`
	SYSOS=`uname -r`
	SYSTYPE=`uname -s`
	if [ "$SYSTYPE" = "AIX" ]
	then
		ARCH="RS6000"
		SYSOS="3.1"
	fi
	if [ "$SYSTYPE" = "HP-UX" ]
	then
		ARCH="hp9000"
		SYSOS="8.7"
	fi
fi
#
#
if [ "$SYSOS" = "" ]
then
	FOUND_RELEASE=0
	for i in `strings /vmunix | grep Release`
	do
		if [ "$i" = "Release" ]
		then
			FOUND_RELEASE=1
		elif [ $FOUND_RELEASE -eq 1 -a "$SYSOS" = "" ]
		then
			SYSOS=`echo $i | awk '{printf("%.3s", $1)}'`
		fi
	done
fi
#
EXE_ARGS=""
#
while [ $# != 0 ]
do
	EXE_ARGS="$EXE_ARGS $1"
	shift
done
#
exec ${DIR}/${ARCH}_${SYSOS}/pm_command $EXE_ARGS
