#!/bin/bash

# Kill any process leftover from previous run
kill $(ps  aux | grep "[p]ython -m CGIHTTPServer 8080" | awk '{print $2}')
kill $(ps  aux | grep "[p]ython deploy/unifiedlogger.zip" | awk '{print $2}')

# Get path to this script
# $0 contains path to the script file, even if launched from file manager
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
# CD to the script folder
cd "$SCRIPT_PATH"

# Start the Simulator System with the system test script
cd ../webapps
python -m CGIHTTPServer 8080 &
sleep 1
cd ..
java -DCONFIG_DIR=config/devlinux -DPROP_FILE=cad_server_systest.properties -jar deploy/CADserver.jar &
sleep 7
python deploy/unifiedlogger.zip &

sleep 2
java -jar deploy/SimManager.jar system_test_script.xml &

# Start a browser and run the web applications
firefox localhost:8080/einotebook  localhost:8080/cptms localhost:8080/unifiedlogmonitor.html &

