#! /bin/bash
#=======================================================================
# NOTE: This one needs more work...
#-----------------------------------------------------------------------
scriptPath="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

baseDir=/opt/sek_ase_auditor
configFile=${baseDir}/conf/sek_ase_auditor.properties
consoleLogFile=${baseDir}/0/log/sek_ase_auditor.console

##
## Start the auditor
##
echo ""
echo " * Starting 'sek_ase_auditor'"
echo ""
nohup ${baseDir}/0/bin/sek_ase_auditor.sh -C ${configFile} 2>&1 | head -c 100M > ${consoleLogFile}

echo " * Sleeping for 3 seconds, then test if 'sek_ase_auditor' is running..."
sleep 3
${scriptPath}/list_auditor.sh

if [ $? -ne 0 ]
then
	echo ""
	echo "===================================================================="
	cat ${consoleLogFile}
	echo "===================================================================="
	echo " * FAILED to start 'sek_ase_auditor'"
	echo " * Above is the latest console log file: ${consoleLogFile}"
fi
