#! /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-.}'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \
  \| .`
#
#
#
#	We need the system architecture and the version to
#	determine which executable to run.
#
#
ARCH=""
if [ -f /bin/arch ]
then
	ARCH=`arch`
else
	ARCH=`uname -m`
fi
#
#	Handle Sun architectures
#
SUNARCH=`echo $ARCH | awk '{printf("%.4s", $1)}'`
if [ "$SUNARCH" = "sun4" ]
then
	ARCH="sun4"
fi
#
#
SYSTYPE=`uname -s`
if [ "$SYSTYPE" = "AIX" ]
then
	ARCH="RS6000"
	SYSOS="3.2"
elif [ "$SYSTYPE" = "HP-UX" ]
then
	ARCH="hp9000"
	SYSOS="9.3"
else
	SYSOS=`uname -r | awk '{printf("%.3s", $1)}'`
fi
#
#
if [ "$ARCH" = "" ]
then
	echo "Unknown system type"
	exit -1
fi
if [ "$SYSOS" = "" ]
then
	echo "Unknown system release"
	exit -1
fi
#
EXE_ARGS=""
#
while [ $# != 0 ]
do
	EXE_ARGS="$EXE_ARGS $1"
	shift
done
#
exec ${DIR}/${ARCH}_${SYSOS}/pm_command $EXE_ARGS
