#!/bin/sh
# $Id: //depot/prod/davit/Rdavit2.0/src/bin/agent#1 $
# Copyright (c) 2008 NetApp, Inc.
# All rights reserved.
#

if [ -z "$JAVA_HOME" ] ; then
    echo JAVA_HOME must be defined
    exit 1;
fi

# All paths are relative to here
#
INSTALL_DIR=/opt/NetApp/ssc

# use the server classes path for the server start boot path stuff
WEB_INF_PATH=${INSTALL_DIR}/webapp/server/WEB-INF
LIB_PATH=${INSTALL_DIR}/lib

# TODO, jar the ssc classes and get those from the lib path
#CP=$WEB_INF_PATH:$WEB_INF_PATH/classes
CP=$LIB_PATH:$WEB_INF_PATH/classes

for file in `find ${LIB_PATH} -follow -name "*.jar"`; do
    CP=$CP:$file
done

CP=${INSTALL_DIR}/etc:${INSTALL_DIR}/properties/cli/agent:$CP

# If shell is killed the java process will keep running as zombie and user will see no message.
# To kill java process, send it a TERM instead of this shell.
trap /bin/true TERM

umask 0000

${JAVA_HOME}/bin/java -cp $CP -Dinstall.dir=/opt/NetApp/ssc -Dcommon.dir=$OUTPUT_DIR com.netapp.davit.agent.cli.AgentMain "$@"

exit $?
