#!/bin/sh

CURR_DIR=`pwd`

CTASD=`test -h $0 && readlink $0 2> /dev/null`

if [ "$CTASD" = "" ] 
then
	CTASD=$0;
fi

CTASD_PATH=`dirname $CTASD`

echo running ctasd from $CTASD_PATH

# this is required in order for ctasd to find its loader.
cd $CTASD_PATH

if [ "$OSBIN" = "" ]
then
	OSBIN="oslib"
	if [ `uname -r | grep  "^2.6"` ]; then 
		`test -d "./oslib_kernel26"` && OSBIN="oslib_kernel26"; 
	fi   
	if [ `uname -r | grep  "^2.4"` ]; then 
		`test -d "./oslib_kernel24"` && OSBIN="oslib_kernel24"; 
	fi 
fi

CMD="./ctasd.bin -l $CURR_DIR $@"

# tell the loader where his libs are
touch stdin.tmp
touch stdout.tmp
touch stderr.tmp
LD_LIBRARY_PATH=`pwd`:`pwd`/$OSBIN:$LD_LIBRARY_PATH $CMD <stdin.tmp >stdout.tmp 2>stderr.tmp
