#!/usr/bin/env bash
#############################################
## This script will launch FakeRaT in the interactive mode.
## It will get the latest orbit and set the necessary
## environment variables for you. Just enjoy :)
#############################################
#############################################
## Set the environment variables
#############################################
FAKERAT_PATH=`readlink -f $0`
export FAKERAT_PATH=`dirname $FAKERAT_PATH`
#export FAKERATLIB_PATH=`dirname $FAKERAT_PATH`/fakerat_lib_4.3.6_v1
export FAKERATLIB_PATH=`dirname $FAKERAT_PATH`/fakerat_lib_4.9.4_v22
export PATH=$FAKERAT_PATH:$FAKERATLIB_PATH:$PATH
#############################################
# Change directory to where FakeRaT is
cd $FAKERAT_PATH
#############################################
## Update orbit
#############################################
./autofake.sh update
if [ $? -ne 0 ];then
 echo "
 ERROR running the automatic orbit update!!!!!!!!!!!!!!!

 ##### Please make sure you manually set up the latest orbit in orbit/ra_orbit #####

 " 
fi
# Check that the orbit file is actually there
if [ ! -f orbit/ra_orbit ];then
 echo "ERROR: the orbit file is not found at orbit/ra_orbit"
 exit 1
fi
#############################################
## Run the original run script that will run FakeRaT
#############################################
./run -c
