head	1.6;
access;
symbols;
locks; strict;
comment	@# @;


1.6
date	2002.03.30.14.51.12;	author znerd;	state dead;
branches;
next	1.5;

1.5
date	2002.02.25.08.02.51;	author znerd;	state Exp;
branches;
next	1.4;

1.4
date	2002.02.21.20.06.55;	author znerd;	state Exp;
branches;
next	1.3;

1.3
date	2002.02.19.13.53.41;	author znerd;	state Exp;
branches;
next	1.2;

1.2
date	2002.02.19.08.20.39;	author znerd;	state Exp;
branches;
next	1.1;

1.1
date	2002.02.04.13.39.20;	author znerd;	state Exp;
branches;
next	;


desc
@@


1.6
log
@Lot of changes: Using USE_JAVA infrastructure. Upgraded port
to 3.3.1. Using HTTP_PORT i.s.o. LISTEN_PORT. Using
daemonctl.c i.s.o. tomcatctl shell script. Displaying steps
i.s.o. commands being executed. Synced man page.
@
text
@#!/bin/sh

# Set some variables
APP_HOME=%%APP_HOME%%
STDOUT_LOG=%%STDOUT_LOG%%
STDERR_LOG=%%STDERR_LOG%%
JAR_FILE=${APP_HOME}/lib/webserver.jar
MYSELF=`basename $0`

# Set the CLASSPATH
unset CLASSPATH
for i in ${APP_HOME}/lib/* ; do
	if [ "$CLASSPATH" != "" ]; then
		CLASSPATH=${CLASSPATH}:$i
	else
		CLASSPATH=$i
	fi
done

# Check if the JAVA_HOME directory is defined, otherwise set it to the
# fallback default
if [ "${JAVA_HOME}a" = "a" ]; then
	JAVA_HOME=%%JAVA_HOME%%
fi
if [ -f ${JAVA_HOME}/lib/tools.jar ] ; then
	CLASSPATH=${CLASSPATH}:${JAVA_HOME}/lib/tools.jar
fi
JAVA_CMD=${JAVA_HOME}/bin/java


##############################################################################
# Function that shows an error message
#
# This function is called by the 'checks' function
#
# Parameters:
#     1: The message to be displayed.

error() {
	echo -n "%%APP_SHORTNAME%%: ERROR: "
	echo $1
}


##############################################################################
# Function that performs all checks necessary for starting or stopping the
# application.
#
# This function is called by the 'start' and 'stop' functions
#
# This function expects no parameters

checks() {
	# Make sure the application directory does exist
	if [ ! -d ${APP_HOME} ]; then
		error "Unable to find %%APP_TITLE%% home directory at ${APP_HOME}."
		exit 2
	fi

	# Make sure the application JAR file exists
	if [ ! -r ${JAR_FILE} ]; then
		error "Unable to find %%APP_TITLE%% JAR file at ${JAR_FILE}."
		exit 3
	fi

	# Make sure the Java VM can be found
	if [ ! -x ${JAVA_CMD} ]; then
		error "Unable to find Java VM at ${JAVA_HOME}."
		exit 4
	fi
}


##############################################################################
# Functions that calls the application with the specified parameter
#
# Parameters:
#    1: The argument to pass to the application (optional)

app() {
	(cd ${APP_HOME} && ${JAVA_CMD} -cp ${CLASSPATH} -Dtomcat.home=${APP_HOME} org.apache.tomcat.startup.Tomcat $1 &) >> ${STDOUT_LOG} 2>> ${STDERR_LOG}
}


##############################################################################
# Function that starts the application
#
# This function is called from the main function
#
# This function expects no parameters

start() {
	# Perform the checks
	checks

	# Stop the application
	app
}


##############################################################################
# Function that stops the application
#
# This function is called from the main function
#
# This function expects no parameters

stop() {
	# Perform the checks
	checks

	# Stop the application
	app -stop
}


##############################################################################
# Main function. This function calls the 'start' and 'stop' functions.
#
# Parameters:
#    1: The argument to this shell script

main() {
	case "$1" in
		start)
			start
			;;
		stop)
			stop
			;;
		restart)
			stop
			start
			;;
		*)
			echo "Usage: ${MYSELF} { start | stop | restart }"
			exit 64
			;;
	esac
}


# Call the main function and exit
main $1
exit 0
@


1.5
log
@Now sets the CLASSPATH *after* JAVA_HOME is determined.

Reported by: Clive Lin <clive@@tongi.org>
@
text
@@


1.4
log
@Cleaned things up. Made things working :-) Both the startup script
in ${PREFIX}/etc/rc.d and the control script in ${PREFIX}/bin have
been refactored and now actually work very well.

Using the 'www' user and group, creating them if they don't exist.
I've used the same approach as www/apache13.

STDOUT_LOG and STDERR_LOG are now fixed (no ?= anymore) since the
package deinstall does not support a different location.

This fixes the first half of PR 28624.
See: http://www.freebsd.org/cgi/query-pr.cgi?pr=34931

Reported by:	Kees Jan Koster <k.j.koster@@kpn.com>
@
text
@a18 3
if [ -f ${JAVA_HOME}/lib/tools.jar ] ; then
	CLASSPATH=${CLASSPATH}:${JAVA_HOME}/lib/tools.jar
fi
d24 3
@


1.3
log
@Reverting changes. Accidentally committed *all* changes in my working copy, instead of only removing the second APP_TITLE from the Makefile.
@
text
@a3 1
VERSION=%%PORTVERSION%%
a4 1
USER_NAME=%%USER_NAME%%
a22 7
# Check if we're being run as a shell script or as an rc script
if [ ${MYSELF} = "%%RC_SCRIPT_NAME%%" ]; then
	AS_RC_SCRIPT=yes
else
	AS_RC_SCRIPT=no
fi

d30 24
a53 2
# Function that starts the application
start() {
d56 1
a56 4
		if [ "${AS_RC_SCRIPT}" = "yes" ]; then
			echo ""
		fi
		echo "%%APP_SHORTNAME%%: ERROR: Unable to find %%APP_TITLE%% home directory at ${APP_HOME}."
d62 1
a62 4
		if [ "${AS_RC_SCRIPT}" = "yes" ]; then
			echo ""
		fi
		echo "%%APP_SHORTNAME%%: ERROR: Unable to find %%APP_TITLE%% JAR file at ${JAR_FILE}."
d68 1
a68 4
		if [ "${AS_RC_SCRIPT}" = "yes" ]; then
			echo ""
		fi
		echo "%%APP_SHORTNAME%%: ERROR: Unable to find Java VM at ${JAVA_HOME}."
d71 12
d84 14
a97 4
	if [ "${AS_RC_SCRIPT}" = "yes" ]; then
		echo -n " %%APP_SHORTNAME%%"
	fi
	su - ${USER_NAME} -c "(cd ${APP_HOME} && ${JAVA_CMD} -cp ${CLASSPATH} -Dtomcat.home=${APP_HOME} org.apache.tomcat.startup.Tomcat) >> ${STDOUT_LOG} 2>> ${STDERR_LOG}"
d100 2
d103 5
d109 31
a139 4
	if [ "${AS_RC_SCRIPT}" = "yes" ]; then
		echo -n " %%APP_SHORTNAME%%"
	fi
	su - ${USER_NAME} -c "(cd ${APP_HOME} && ${JAVA_CMD} -cp ${CLASSPATH} -Dtomcat.home=${APP_HOME} org.apache.tomcat.startup.Tomcat -stop) >> ${STDOUT_LOG} 2>> ${STDERR_LOG}"
d142 4
a145 18
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		stop
		start
		;;
	*)
		echo ""
		echo "Usage: ${MYSELF} { start | stop | restart }"
		echo ""
		exit 64
		;;
esac
@


1.2
log
@APP_TITLE was set twice.

Reported by: Kimura Fuyuki <fuyuki@@mj.0038.net>
@
text
@d6 1
d25 7
d39 2
a40 24

##############################################################################
# Function that shows an error message
#
# This function is called by the 'checks' function
#
# Parameters:
#     1: The message to be displayed.

error() {
	echo -n "%%APP_SHORTNAME%%: ERROR: "
	echo $1
}


##############################################################################
# Function that performs all checks necessary for starting or stopping the
# application.
#
# This function is called by the 'start' and 'stop' functions
#
# This function expects no parameters

checks() {
d43 4
a46 1
		error "Unable to find %%APP_TITLE%% home directory at ${APP_HOME}."
d52 4
a55 1
		error "Unable to find %%APP_TITLE%% JAR file at ${JAR_FILE}."
d61 4
a64 1
		error "Unable to find Java VM at ${JAVA_HOME}."
a66 1
}
d68 4
a71 25

##############################################################################
# Functions that calls the application with the specified parameter
#
# Parameters:
#    1: The argument to pass to the application (optional)

app() {
	(cd ${APP_HOME} && ${JAVA_CMD} -cp ${CLASSPATH} -Dtomcat.home=${APP_HOME} org.apache.tomcat.startup.Tomcat $1) >> ${STDOUT_LOG} 2>> ${STDERR_LOG}
}


##############################################################################
# Function that starts the application
#
# This function is called from the main function
#
# This function expects no parameters

start() {
	# Perform the checks
	checks

	# Stop the application
	app
a73 2

##############################################################################
a74 5
#
# This function is called from the main function
#
# This function expects no parameters

d76 4
a79 5
	# Perform the checks
	checks

	# Stop the application
	app -stop
d82 18
a99 30

##############################################################################
# Main function. This function calls the 'start' and 'stop' functions.
#
# Parameters:
#    1: The argument to this shell script

main() {
	case "$1" in
		start)
			start
			;;
		stop)
			stop
			;;
		restart)
			stop
			start
			;;
		*)
			echo "Usage: ${MYSELF} { start | stop | restart }"
			exit 64
			;;
	esac
}


# Call the main function and exit
main $1
exit 0
@


1.1
log
@A new tomcatctl control script, installed in /bin.
@
text
@a5 1
USER_NAME=%%USER_NAME%%
a23 7
# Check if we're being run as a shell script or as an rc script
if [ ${MYSELF} = "%%RC_SCRIPT_NAME%%" ]; then
	AS_RC_SCRIPT=yes
else
	AS_RC_SCRIPT=no
fi

d31 24
a54 2
# Function that starts the application
start() {
d57 1
a57 4
		if [ "${AS_RC_SCRIPT}" = "yes" ]; then
			echo ""
		fi
		echo "%%APP_SHORTNAME%%: ERROR: Unable to find %%APP_TITLE%% home directory at ${APP_HOME}."
d63 1
a63 4
		if [ "${AS_RC_SCRIPT}" = "yes" ]; then
			echo ""
		fi
		echo "%%APP_SHORTNAME%%: ERROR: Unable to find %%APP_TITLE%% JAR file at ${JAR_FILE}."
d69 1
a69 4
		if [ "${AS_RC_SCRIPT}" = "yes" ]; then
			echo ""
		fi
		echo "%%APP_SHORTNAME%%: ERROR: Unable to find Java VM at ${JAVA_HOME}."
d72 12
d85 14
a98 4
	if [ "${AS_RC_SCRIPT}" = "yes" ]; then
		echo -n " %%APP_SHORTNAME%%"
	fi
	su - ${USER_NAME} -c "(cd ${APP_HOME} && ${JAVA_CMD} -cp ${CLASSPATH} -Dtomcat.home=${APP_HOME} org.apache.tomcat.startup.Tomcat) >> ${STDOUT_LOG} 2>> ${STDERR_LOG}"
d101 2
d104 5
d110 31
a140 4
	if [ "${AS_RC_SCRIPT}" = "yes" ]; then
		echo -n " %%APP_SHORTNAME%%"
	fi
	su - ${USER_NAME} -c "(cd ${APP_HOME} && ${JAVA_CMD} -cp ${CLASSPATH} -Dtomcat.home=${APP_HOME} org.apache.tomcat.startup.Tomcat -stop) >> ${STDOUT_LOG} 2>> ${STDERR_LOG}"
d143 4
a146 18
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		stop
		start
		;;
	*)
		echo ""
		echo "Usage: ${MYSELF} { start | stop | restart }"
		echo ""
		exit 64
		;;
esac
@

