#!/bin/sh
#
# orbplus startup script 
#

APP_NAME=xcrvfit

# imagine we startup in current directory as the script
parentdir="$( cd -P "$( dirname "$0" )" && pwd )"
cd $parentdir

# here is where we look for the software
# desktop has priority
p1=$HOME/Desktop/$APP_NAME.app/Contents/MacOS/$APP_NAME
p2=$HOME/Desktop/$APP_NAME/$APP_NAME
#
# then check /Applications 
p3=/Applications/$APP_NAME.app/Contents/MacOS/$APP_NAME
p4=/Applications/bdslab/$APP_NAME.app/Contents/MacOS/$APP_NAME
p5=/Applications/packages/$APP_NAME.app/Contents/MacOS/$APP_NAME
#
# check /usr/local or /usr/local/bdslab
p6=/usr/local/$APP_NAME/$APP_NAME
p7=/usr/local/bdslab/$APP_NAME/$APP_NAME
p8=/usr/local/packages/$APP_NAME/$APP_NAME

# stop when we have found an executable
APP_LIST="$p1 $p2 $p3 $p4 $p5 $p6 $p7 $p8"
prog=""
for i in $APP_LIST; do
	if ( test -x $i ) then
		prog=$i
		break
	fi
done

if ( test -x $prog) then
	# start program 
	$prog &
else
	# did not find software
	echo "Cannot find $APP_NAME executable on this machine."
fi
exit
