#!/bin/sh

# Disable generating coredumps
ulimit -c 0

export LD_LIBRARY_PATH=/usr/lib/te-etm-agent
export GOTRACEBACK=crash

echo "Starting te-etm-agent ..."
exec /usr/bin/te-etm-agent -config-file /etc/te-etm-agent-config -te-config-file /var/lib/te-agent/identity.json -te-text-config-file /etc/te-agent.cfg

# Wait ten seconds after the agent exits. This is only executed when the agent
# exits via a non-normal exit. When stop or restart are called, the whole
# script is killed and this line is not executed.
STATUS=$?
if [ $STATUS -ne 0 ]; then
    sleep 10
fi

exit $STATUS