#!/bin/sh
CLASSPATH=.:/opt/egurkha/lib/eg_agent.jar:/opt/egurkha/agent/lib/jboss/jboss-cli-client.jar:$CLASSPATH
export CLASSPATH
isJRE16=`/opt/egurkha/jre/bin/java -version 2>&1 | grep "1.6" | wc -l`
isJRE17=`/opt/egurkha/jre/bin/java -version 2>&1 | grep "1.7" | wc -l`
if [ $isJRE17 -ne 1 ]
then
	isJRE17=`/opt/egurkha/jre/bin/java -version 2>&1 | grep "1.8" | wc -l`
fi
isJRE10=`/opt/egurkha/jre/bin/java -version 2>&1 | grep "10\." | wc -l`
export isJRE16
export isJRE17
export isJRE10

javaCmd="java "
if [ "$isJRE16" -ge "1" ]
then
        javaCmd="java -XX:ErrorFile=/dev/null -XX:HeapDumpPath=/dev/null "
fi
if [ "$isJRE17" -ge "1" ]
then
        javaCmd="java -XX:ErrorFile=/dev/null -XX:HeapDumpPath=/dev/null -XX:-CreateMinidumpOnCrash "
 fi
 
if [ "$isJRE10" -ge "1" ]
then
        javaCmd="java -XX:ErrorFile=/dev/null -XX:HeapDumpPath=/dev/null -XX:-CreateCoredumpOnCrash "
 fi
 
 /opt/egurkha/jre/bin/$javaCmd com.eg.MBeanDiscover
