#!/bin/bash
# IBM Confidential
# OCO Source Materials
# 5724-V51
#
# (c) Copyright IBM Corp. 2000, 2008 All Rights Reserved.
#
# The source code for this program is not published or otherwise
# divested of its trade secrets, irrespective of what has been
# deposited with the U.S. Copyright Office.

. ${TOP}/bin/get_params.sh
if [ ! "${_CCD_STOP}" = "no" ]; then
    ${ADMIN_DIR}/abort/abort_appsvr.sh
fi

SVC_NAME=appsvr_${SHORT_HOSTNAME}
. ${ADMIN_DIR}/init_svc_vars.sh

${ECHO} "starting service '${SVC_NAME}'"
cd $TOP

case "${CCD_APPSVR}" in
    tomcat)
        cd ${TOP}/etc/default/tomcat
        ${RM} ${TOP}/logs/tomcat/work/*

        startWithLogs ${JDK_HOME}/bin/java \
            ${APPSVR_OPTS} \
            ${CCD_APPSVR_JVM_DEBUG_OPTS}\
            -classpath ${CCD_CLASSPATH} \
            -Dtomcat.home=${TOMCAT_HOME} \
            -Xdebug -Xnoagent -Djava.compiler=NONE \
            -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 \
            org.apache.tomcat.startup.Tomcat \
            -f ${TOP}/etc/default/tomcat/server.xml \
        ;;
    tomcat60)
        cd ${TOP}/etc/default/tomcat60
        ${RM} ${TOP}/logs/tomcat/work/*

        startWithLogs ${JDK_HOME}/bin/java \
            ${APPSVR_OPTS} \
            ${CCD_APPSVR_JVM_DEBUG_OPTS}\
            -classpath ${CCD_CLASSPATH} \
            -Dtomcat.home=${TOMCAT_HOME} \
            -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=59103 \
            org.apache.tomcat.startup.Main \
            -f ${TOP}/etc/default/tomcat60/server.xml \
        ;;

    weblogic92)
        cd ${CCD_WL_DOMAIN_DIR}
        export CLASSPATH=
        . ./setEnv.sh
        export CLASSPATH=${CCD_CLASSPATH}${PATH_SEPARATOR}${CLASSPATH}
        cd ../..

        STARTMODE=true
        BEA_HOME=`cd ${WL_HOME}/..; pwd`

        startWithLogs ${JDK_HOME}/bin/java \
            ${APPSVR_OPTS} \
            ${CCD_APPSVR_JVM_DEBUG_OPTS}\
            -classpath ${CLASSPATH} \
            -Dweblogic.Domain=${CCD_WL_DOMAIN} \
            -Dweblogic.Name=${CCD_WL_SERVER} \
            -Dbea.home=${BEA_HOME} \
            -Dweblogic.management.password=${CCD_WL_PW} \
            -Dweblogic.ProductionModeEnabled=${STARTMODE} \
            -Djava.security.policy==${WL_HOME}/lib/weblogic.policy \
            weblogic.Server
        ;;

    *)
        ${ECHO} "$0: Error!: CCD_APPSVR set to \"$CCD_APPSVR\". Unknown value"
        ;;
esac
