#!/bin/sh
#
#	Start the appropriate pvmd3.
#	If PVM_ROOT is not set in environment,
#		we try to guess it by combining the working directory with argv[0],
#		otherwise it defaults to ~/pvm3.
#	If PVM_ARCH is not set,
#		we get it by execing $PVMROOT/lib/pvmgetarch.
#
#	03 Jun 1994  Manchek
#

case "x$PVM_ROOT" in x )
	case "$0" in
	/*) PVM_ROOT="$0" ;;
	*) PVM_ROOT=`pwd`/"$0" ;;
	esac
	PVM_ROOT=`echo "$PVM_ROOT" | sed -e 's/\/lib\/pvmd//'`
	if [ -d $PVM_ROOT ]; then
		export PVM_ROOT
	else
		if [ -d $HOME/pvm3 ]; then
			PVM_ROOT=$HOME/pvm3
			export PVM_ROOT
		else
			echo pvmd: PVM_ROOT not defined >&2
			exit 1
		fi
	fi
;; esac

case "x$PVM_ARCH" in x | xUNKNOWN )
	PVM_ARCH="`$PVM_ROOT/lib/pvmgetarch`"
	case "x$PVM_ARCH" in x )
		echo pvmd: can\'t set arch >&2
		exit 1
	;; esac
;; esac

export PVM_ARCH

filename=`echo $0 |sed -e "s|master1$|$PVM_ARCH/master1|"`

if [ ! -f $filename ]; then
	echo "$filename doesn't exist." >&2
	echo "Make sure Tkpvm is built" >&2
	exit 1
fi
exec $filename $@
exit 1

