295e28
#!/bin/bash
295e28
295e28
if [ -r /usr/share/java-utils/java-functions ]; then
04fb17
    . /usr/share/java-utils/java-functions
295e28
else
04fb17
    echo "Can't read Java functions library, aborting"
04fb17
    exit 1
295e28
fi
295e28
295e28
_save_function() {
295e28
    local ORIG_FUNC=$(declare -f $1)
295e28
    local NEWNAME_FUNC="$2${ORIG_FUNC#$1}"
295e28
    eval "$NEWNAME_FUNC"
295e28
}
295e28
295e28
run_jsvc(){
295e28
    if [ -x /usr/bin/jsvc ]; then
04fb17
        TOMCAT_USER="${TOMCAT_USER:-tomcat}"
04fb17
        JSVC="/usr/bin/jsvc"
295e28
	
04fb17
        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"
04fb17
        if [ "$1" = "stop" ]; then
04fb17
            JSVC_OPTS="${JSVC_OPTS} -stop"
04fb17
        fi
295e28
295e28
        exec "${JSVC}" ${JSVC_OPTS} ${FLAGS} -classpath "${CLASSPATH}" ${OPTIONS} "${MAIN_CLASS}" "${@}"
295e28
    else
295e28
       	echo "Can't find /usr/bin/jsvc executable"
295e28
    fi
295e28
}
295e28
295e28
_save_function run run_java
295e28
295e28
run() {
04fb17
    if [ "${USE_JSVC}" = "true" ] ; then
04fb17
        run_jsvc $@
04fb17
    else
04fb17
        run_java $@
04fb17
    fi
295e28
}
295e28