#!/usr/bin/env bash

BASE_DIR="$(cd "$(dirname "$0")"; pwd)";

export CONTAINER_IP=`cat /etc/hosts | egrep -v "ip6-|local|Kubernetes-managed" | awk '{print $1}'`
export CONTAINER_NAME=`cat /etc/hosts | egrep -v "ip6-|local|Kubernetes-managed" | awk '{print $2}'`

. $BASE_DIR/env.sh

if [ $JAVA_HOME ] ; then
    EXE_JAVA=$JAVA_HOME/bin/java
else
    EXE_JAVA=java
fi

# Change directory to create host.id file in BASE_DIR
cd $BASE_DIR

nohup $EXE_JAVA $JAVA_OPTS -jar $BASE_DIR/../lib/wasup-agent.jar > /dev/null 2>&1 &
