828cdb
#!/bin/bash
828cdb
828cdb
if [ -r /usr/share/java-utils/java-functions ]; then
828cdb
    . /usr/share/java-utils/java-functions
828cdb
else
828cdb
    echo "Can't read Java functions library, aborting"
828cdb
    exit 1
828cdb
fi
828cdb
828cdb
_save_function() {
828cdb
    local ORIG_FUNC=$(declare -f $1)
828cdb
    local NEWNAME_FUNC="$2${ORIG_FUNC#$1}"
828cdb
    eval "$NEWNAME_FUNC"
828cdb
}
828cdb
828cdb
run_jsvc(){
828cdb
    if [ -x /usr/bin/jsvc ]; then
828cdb
        TOMCAT_USER="${TOMCAT_USER:-tomcat}"
828cdb
        JSVC="/usr/bin/jsvc"
828cdb
	
828cdb
        JSVC_OPTS="-nodetach -pidfile /var/run/jsvc-tomcat${NAME}.pid -user ${TOMCAT_USER} -outfile ${CATALINA_BASE}/logs/catalina.out -errfile ${CATALINA_BASE}/logs/catalina.out"
828cdb
        if [ "$1" = "stop" ]; then
828cdb
            JSVC_OPTS="${JSVC_OPTS} -stop"
828cdb
        fi
828cdb
828cdb
        exec "${JSVC}" ${JSVC_OPTS} ${FLAGS} -classpath "${CLASSPATH}" ${OPTIONS} "${MAIN_CLASS}" "${@}"
828cdb
    else
828cdb
       	echo "Can't find /usr/bin/jsvc executable"
828cdb
    fi
828cdb
}
828cdb
828cdb
_save_function run run_java
828cdb
828cdb
run() {
828cdb
    if [ "${USE_JSVC}" = "true" ] ; then
828cdb
        run_jsvc $@
828cdb
    else
828cdb
        run_java $@
828cdb
    fi
828cdb
}
828cdb