#!/bin/bash
# SANDBOX_DIR should refer to the directory in which sandbox is placed.
#SANDBOX_DIR=~/sandbox
#SANDBOX_DIR=/usr/local/sandbox
SANDBOX_DIR=.

SANDBOX_OPTIONS="-r"
#SANDBOX_OPTIONS="-q${HOME}/.platinumarts -r"

if [ -a ${SANDBOX_DIR}/bin/sandbox_client_$(uname -m) ]
then
	cd ${SANDBOX_DIR}
	chmod +x ./bin/sandbox_*
	exec ./bin/sandbox_client_$(uname -m) ${SANDBOX_OPTIONS} $*
else
	echo "A problem was encountered, please check which of the following it is."
	echo "1) There isn't an available executable for your platform $(uname -m)"
	echo "2) the executable was moved"
	echo "3) There isn't an executable"
	echo "the script will attempt to create a client in 10 seconds, press CTRL-C to cancel"
	sleep 10
	cd src
	chmod +x build.sh
	exec build.sh
	cd ../
	exit 1
fi
