#!/bin/bash

here="${0%/*}"  # or you can use `dirname "$0"`
app_type=`cat "$here"/com.forescout.secureconnector.json | grep -Po '(?<="app_type": ")[^"]*' `

if [ "$app_type" = "dissolvable" ]
then
	argument="-local";
fi
if [ "$app_type" = "daemon" ]
then
	argument="-daemon";
fi

LD_LIBRARY_PATH="$here"/lib:$LD_LIBRARY_PATH
echo "ForeScoutSecureConnector ($$) `date` : LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> "$here"/log/fs_sc.log
export LD_LIBRARY_PATH
export QT_PLUGIN_PATH="$here"/lib/plugins
export QT_LOGGING_RULES='*.debug=true'

exec "$0".bin "$argument"

if [ "$app_type" = "daemon" ]
then
	exec "$here"/"$0"Agent
fi

