#!/bin/sh

# find SN base installation directory
me=`realpath $0`
snbindir=`dirname $me`
snbasedir=`cd $snbindir/.. ; pwd`
startup=hyper
script=snavigator

# find the main "hyper" executable
for dir in libexec/snavigator libexec bin; do
	try="$snbasedir/$dir/$startup"
  	run=""
	
	#echo "testing for: $try"
	if test -f "$try"; then
		run="$try"
		break
	fi
done
#echo "debug: found $startup at $run"


# find the desired script
for dir in share/snavigator/etc share/snavigator share/etc; do
	try="$snbasedir/$dir/$script"
  	runscript=""

	#echo "testing for: $try"
	if test -f "$try"; then
		runscript="$try"
		break
	fi
done              	
#echo "debug: found $script at $runscript"


# and run it
exec "$run" --home "$snbasedir" -file "$runscript" ${1+"$@"}
