diff options
author | Ernst de Haan <znerd@FreeBSD.org> | 2002-03-05 01:21:39 +0000 |
---|---|---|
committer | Ernst de Haan <znerd@FreeBSD.org> | 2002-03-05 01:21:39 +0000 |
commit | 3030eab564bb4c87108603cd2c1c3f1d0f6fb608 (patch) | |
tree | 0bb41c788e6f33eae5f1dafd50fb9b7e7bb391b8 /www/orion | |
parent | a8e398e1a960c9a54fec7684f89b57fdbb480e17 (diff) | |
download | ports-3030eab564bb4c87108603cd2c1c3f1d0f6fb608.tar.gz ports-3030eab564bb4c87108603cd2c1c3f1d0f6fb608.zip |
Notes
Diffstat (limited to 'www/orion')
-rw-r--r-- | www/orion/Makefile | 46 | ||||
-rw-r--r-- | www/orion/files/orion.sh | 20 | ||||
-rw-r--r-- | www/orion/files/orionctl | 198 | ||||
-rw-r--r-- | www/orion/files/orionctl.1 | 86 |
4 files changed, 200 insertions, 150 deletions
diff --git a/www/orion/Makefile b/www/orion/Makefile index 73bb56825960..9261c743f3d5 100644 --- a/www/orion/Makefile +++ b/www/orion/Makefile @@ -7,7 +7,7 @@ PORTNAME= orion PORTVERSION= 1.5.2 -PORTREVISION= 4 +PORTREVISION= 5 CATEGORIES= www java MASTER_SITES= http://www.orionserver.com/distributions/ \ http://www.atlassian.com/software/orion/downloads/ \ @@ -30,10 +30,10 @@ LOG_DIR= ${APP_HOME}/log PLIST_SUB+= T=${APP_HOME:S/^${PREFIX}\///} APP_TITLE= Orion Server APP_SHORTNAME= ${PORTNAME} -APPCTL_NAME= ${APP_SHORTNAME}ctl -CTL_SCRIPT= ${PREFIX}/bin/${APPCTL_NAME} +CONTROL_SCRIPT_NAME= ${APP_SHORTNAME}ctl +CONTROL_SCRIPT= ${PREFIX}/bin/${CONTROL_SCRIPT_NAME} STARTUP_ORDER= 020 -RC_SCRIPT= ${PREFIX}/etc/rc.d/${STARTUP_ORDER}.${PORTNAME}.sh +STARTUP_SCRIPT= ${PREFIX}/etc/rc.d/${STARTUP_ORDER}.${PORTNAME}.sh JAVA_HOME?= ${LOCALBASE}/jdk1.3.1 JAVA_PORT?= ${PORTSDIR}/java/jdk13 JIKES_LOCATION= ${LOCALBASE}/bin/jikes @@ -46,13 +46,16 @@ GROUP_NAME= www PW?= /usr/sbin/pw HTTP_PORT?= 8090 RMI_PORT?= 23791 +STDOUT_LOG= ${LOG_DIR}/stdout.log +STDERR_LOG= ${LOG_DIR}/stderr.log AUTO_START?= NO +PID_FILE= /var/run/orion.pid pre-install: @${ECHO} "Installation settings:" @${ECHO} " Destination directory: ${APP_HOME}" - @${ECHO} " Control script location: ${CTL_SCRIPT}" - @${ECHO} " Startup script location: ${RC_SCRIPT}" + @${ECHO} " Control script location: ${CONTROL_SCRIPT}" + @${ECHO} " Startup script location: ${STARTUP_SCRIPT}" @${ECHO} " Location of JDK: ${JAVA_HOME}" @${ECHO} " Location of Java port: ${JAVA_PORT}" @${ECHO} " Using Jikes: ${WITH_JIKES}" @@ -62,7 +65,6 @@ pre-install: @${ECHO} " Starting after install: ${AUTO_START}" PKG_PREFIX=${PREFIX} ${SH} pkg-install ${PKGNAME} PRE-INSTALL - do-install: @# Create the destination directory ${MKDIR} ${APP_HOME} @@ -91,7 +93,7 @@ do-install: > ${APP_HOME}/config/rmi.xml @# Install the control script - ${CAT} ${FILESDIR}/${APPCTL_NAME} \ + ${CAT} ${FILESDIR}/${CONTROL_SCRIPT_NAME} \ | ${SED} "/%%PORTNAME%%/s//${PORTNAME}/" \ | ${SED} "/%%PORTVERSION%%/s//${PORTVERSION}/" \ | ${SED} "/%%APP_TITLE%%/s//${APP_TITLE}/" \ @@ -101,11 +103,20 @@ do-install: | ${SED} "/%%RC_SCRIPT_NAME%%/s//${PORTNAME}.sh/" \ | ${SED} "/%%JAVA_HOME%%/s//${JAVA_HOME:S/\//\\\//g}/" \ | ${SED} "/%%USER_NAME%%/s//${USER_NAME}/" \ - > ${CTL_SCRIPT} - ${CHMOD} 755 ${CTL_SCRIPT} + | ${SED} "/%%GROUP_NAME%%/s//${GROUP_NAME}/" \ + | ${SED} "/%%STDOUT_LOG%%/s//${STDOUT_LOG:S/\//\\\//g}/" \ + | ${SED} "/%%STDERR_LOG%%/s//${STDERR_LOG:S/\//\\\//g}/" \ + | ${SED} "/%%PID_FILE%%/s//${PID_FILE:S/\//\\\//g}/" \ + > ${CONTROL_SCRIPT} + ${CHMOD} 755 ${CONTROL_SCRIPT} @# Install the startup script - ${LN} -sf ${CTL_SCRIPT} ${RC_SCRIPT} + ${CAT} ${FILESDIR}/${PORTNAME}.sh \ + | ${SED} "/%%USER_NAME%%/s//${USER_NAME}/" \ + | ${SED} "/%%APP_SHORTNAME%%/s//${APP_SHORTNAME}/" \ + | ${SED} "/%%CONTROL_SCRIPT%%/s//${CONTROL_SCRIPT:S/\//\\\//g}/" \ + > ${STARTUP_SCRIPT} + ${CHMOD} 0554 ${STARTUP_SCRIPT} @# Create the directories that the application will create it at the @# first run @@ -119,20 +130,23 @@ do-install: @# Install the man page .if !defined(NOPORTDOCS) - ${CAT} ${FILESDIR}/${APPCTL_NAME}.1 \ + ${CAT} ${FILESDIR}/${CONTROL_SCRIPT_NAME}.1 \ + | ${SED} "/%%APP_TITLE%%/s//${APP_TITLE}/" \ | ${SED} "/%%PREFIX%%/s//${PREFIX:S/\//\\\//g}/" \ - > ${WRKDIR}/${APPCTL_NAME}.1 - ${INSTALL_MAN} ${WRKDIR}/${APPCTL_NAME}.1 ${MANPREFIX}/man/man1 + | ${SED} "/%%CONTROL_SCRIPT_NAME%%/s//${CONTROL_SCRIPT_NAME}/" \ + | ${SED} "/%%STARTUP_ORDER%%/s//${STARTUP_ORDER}.sh/" \ + > ${WRKDIR}/${CONTROL_SCRIPT_NAME}.1 + ${INSTALL_MAN} ${WRKDIR}/${CONTROL_SCRIPT_NAME}.1 ${MANPREFIX}/man/man1 .endif post-install: @${ECHO} "${APP_TITLE} ${PORTVERSION} has been installed in ${APP_HOME}." .if !defined(NOPORTDOCS) - @${ECHO} "Use 'man ${APPCTL_NAME}' for information about starting and stopping ${APP_TITLE}." + @${ECHO} "Use 'man ${CONTROL_SCRIPT_NAME}' for information about starting and stopping ${APP_TITLE}." .endif .if ${AUTO_START} == "YES" @${ECHO} "Starting ${APP_TITLE}..." - @${CTL_SCRIPT} start || true + @${CONTROL_SCRIPT} start || true .endif .include <bsd.port.mk> diff --git a/www/orion/files/orion.sh b/www/orion/files/orion.sh new file mode 100644 index 000000000000..cbd3e16f99b1 --- /dev/null +++ b/www/orion/files/orion.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Set some variables +USER_NAME=%%USER_NAME%% +MYSELF=`basename $0` + +case "$1" in + start) + su -f -m ${USER_NAME} -c "exec %%CONTROL_SCRIPT%% start" && echo -n ' %%APP_SHORTNAME%%' + ;; + stop) + su -f -m ${USER_NAME} -c "exec %%CONTROL_SCRIPT%% stop" && echo -n ' %%APP_SHORTNAME%%' + ;; + *) + echo "" + echo "Usage: ${MYSELF} { start | stop }" + echo "" + exit 64 + ;; +esac diff --git a/www/orion/files/orionctl b/www/orion/files/orionctl index b6a7193fddd8..eb1114d1cc0c 100644 --- a/www/orion/files/orionctl +++ b/www/orion/files/orionctl @@ -1,118 +1,160 @@ #!/bin/sh # Set some variables -VERSION=%%PORTVERSION%% APP_HOME=%%APP_HOME%% -USER_NAME=%%USER_NAME%% -LOG=%%LOG_DIR%%/%%APP_SHORTNAME%%.log -PID_FILE=/var/run/%%PORTNAME%%.pid -JAR_FILE=${APP_HOME}/%%APP_SHORTNAME%%.jar +STDOUT_LOG=%%STDOUT_LOG%% +STDERR_LOG=%%STDERR_LOG%% +JAR_FILE=${APP_HOME}/orion.jar MYSELF=`basename $0` -# 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 +# 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 starts the application -start() { - # Make sure the application is not started previously - if [ -e ${PID_FILE} ]; then - if [ "${AS_RC_SCRIPT}" = "yes" ]; then - echo "" - fi - echo "%%APP_SHORTNAME%%: ERROR: Found %%APP_TITLE%% PID file at ${PID_FILE}. It is probably already running." - exit 1 - fi +############################################################################## +# 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 - if [ "${AS_RC_SCRIPT}" = "yes" ]; then - echo "" - fi - echo "%%APP_SHORTNAME%%: ERROR: Unable to find %%APP_TITLE%% home directory at ${APP_HOME}." + 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 - if [ "${AS_RC_SCRIPT}" = "yes" ]; then - echo "" - fi - echo "%%APP_SHORTNAME%%: ERROR: Unable to find %%APP_TITLE%% JAR file at ${JAR_FILE}." + 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 - if [ "${AS_RC_SCRIPT}" = "yes" ]; then - echo "" - fi - echo "%%APP_SHORTNAME%%: ERROR: Unable to find Java VM at ${JAVA_HOME}." + error "Unable to find Java VM at ${JAVA_HOME}." exit 4 fi +} - # Create the process ID file - rm -f ${PID_FILE} - touch ${PID_FILE} - chown ${USER_NAME} ${PID_FILE} - chmod 600 ${PID_FILE} - if [ "${AS_RC_SCRIPT}" = "yes" ]; then - echo -n " %%APP_SHORTNAME%%" +############################################################################## +# 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} -jar ${JAR_FILE} $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() { + # Make sure the application is not started previously + if [ -e %%PID_FILE%% ]; then + error "Found %%APP_TITLE%% PID file at %%PID_FILE%%. It is probably already running." + exit 1 fi - touch ${PID_FILE} - chown ${USER_NAME} ${PID_FILE} - chmod 600 ${PID_FILE} - su - ${USER_NAME} -c "(cd ${APP_HOME} && ${JAVA_CMD} -jar ${JAR_FILE} & echo \$! > ${PID_FILE}) > ${LOG} 2>&1" + + # Perform the checks that apply to stopping as well + checks + + # Create the process ID file + rm -f %%PID_FILE%% + touch %%PID_FILE%% + chown %%USER_NAME%%:%%GROUP_NAME%% %%PID_FILE%% + chmod 600 %%PID_FILE%% + (cd ${APP_HOME} && ${JAVA_CMD} -jar ${JAR_FILE} & echo $! > %%PID_FILE%%) >> ${STDOUT_LOG} 2>> ${STDERR_LOG} } + +############################################################################## # Function that stops the application -stop() { - if [ ! -e ${PID_FILE} ]; then +# +# This function is called from the main function +# +# This function expects no parameters - # If run as an rc script, die silently... - if [ "${AS_RC_SCRIPT}" = "yes" ]; then - exit 0 +stop() { + # Perform the checks + checks - # ...otherwise complain - else - echo "%%APP_SHORTNAME%%: ERROR: Unable to find %%APP_TITLE%% PID file at ${PID_FILE}. It is probably not running." - exit 16 - fi - else - if [ "${AS_RC_SCRIPT}" = "yes" ]; then - echo -n " %%APP_SHORTNAME%%" - fi - /bin/kill `cat ${PID_FILE}` - rm -f ${PID_FILE} + # Kill the running program + if [ ! -e %%PID_FILE%% ]; then + error "Unable to find %%APP_TITLE%% PID file at %%PID_FILE%%. It is probably not running." + exit 16 fi + /bin/kill `cat %%PID_FILE%%` + rm -f %%PID_FILE%% } -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop - start - ;; - *) - echo "" - echo "Usage: ${MYSELF} { start | stop | restart }" - echo "" - exit 64 - ;; -esac + +############################################################################## +# 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 diff --git a/www/orion/files/orionctl.1 b/www/orion/files/orionctl.1 index ed82a8ea30ff..c7c2647a75d2 100644 --- a/www/orion/files/orionctl.1 +++ b/www/orion/files/orionctl.1 @@ -1,96 +1,70 @@ -.Dd May 26, 2001 +.Dd February 21, 2002 .Dt ORIONCTL 1 .Os FreeBSD .Sh NAME -.Nm orionctl -.Nd Orion server control interface +.Nm %%CONTROL_SCRIPT_NAME%% +.Nd %%APP_TITLE%% server control interface .Sh SYNOPSIS .Nm -.Op Ar start | Ar stop +.Op Ar start | Ar restart | Ar stop .Sh DESCRIPTION The .Nm -shell script provides an interface to the Orion application server. -.Pp -This script has 2 modes of operation, One is -.Em shell script mode -and the other is -.Em rc script mode . -If run as -.Nm -shell script mode is used, otherwise rc script mode is used. Shell script mode -assumes that the script is used as a normal shell script, while rc script mode -assumes the script is used to start or stop Orion at boot time. +shell script provides an interface to the %%APP_TITLE%% application server. .Pp The script expects exactly one argument, either -.Ar start +.Ar start , +.Ar restart or .Ar stop . If more than one argument is given, then all arguments but the first are ignored. .Bl -tag -width indent .It Ar start -Start Orion, if it is not already running. The ID of the started process will -be saved in a PID file. +Start %%APP_TITLE%%, if it is not already running. +.It Ar restart +Restart %%APP_TITLE%%. If it is already running, then it will be stopped and then +started right after that. Otherwise it will just be started up. .It Ar stop -Stop Orion, if it is actually running. The process with the ID stored in -the PID file will be killed. +Stop %%APP_TITLE%%, if it is actually running. .El .Sh ERRORS The following error conditions are detected. They will be checked in the -specified order. In every case where an error message is printed it will be -prepended by the name of the script -.Em ( basename $0 ) . +specified order. In each case where an error message is printed, the name of +the script +.Em ( basename $0 ) +will be prepended. .Pp If no argument is passed, or if an argument other than -.Ar start +.Ar start , +.Ar restart or .Ar stop is passed as the first argument, then a simple help message is printed and the script is exited with error code 64. .Pp -In -.Em rc script mode -a newline will be printed before any error message. -.Pp -When using the argument -.Ar start -the following errors conditions can be triggered: +Other than that, the following errors conditions are defined: .Bl -tag -width indent -.It Em The Orion PID file already exists. -Orion is probably already running. Prints an error message and exits the -script with error code 1. -.It Em Orion home directory cannot be found +.It Em %%APP_TITLE%% seems to be running already. +Prints an error message and exits the script with error code 1. +.It Em %%APP_TITLE%% home directory cannot be found Prints an error message and exits the script with error code 2. -.It Em Orion JAR file cannot be found +.It Em %%APP_TITLE%% script cannot be found Prints an error message and exits the script with error code 3. .It Em Java VM cannot be found Prints an error message and exits the script with error code 4. .El -.Pp -When using the argument -.Ar stop -the following error condition can be triggered: -.Bl -tag -width indent -.It Em The Orion PID file cannot be found -Orion is probably not running. Prints an error message and exits the script -with error code 16. -.El .Sh FILES .Bl -tag -width -indent .It Pa /var/run/orion.pid -The Orion PID file that is used to store the process ID of the currently -running Orion process in. It is deleted as soon as Orion is stopped and -recreated when Orion is started. It should never be writable for anyone but +The %%APP_TITLE%% PID file that is used to store the process +ID of the currently running process in. It is deleted as soon as the server is +stopped and recreated when it is started. It should never be writable for anyone but .Em root , -.It Pa %%PREFIX%%/etc/rc.d/orion.sh -A symlink to the -.Nm -script. This causes Orion to be started at boot time. When called from this -location the +.It Pa %%PREFIX%%/etc/rc.d/%%STARTUP_ORDER%%.orion.sh +A script that starts the .Nm -script will use -.Em rc script mode . +script. It starts %%APP_TITLE%% at startup time. .El .Sh AUTHORS -.An Ernst de Haan Aq ernst@jollem.com +.An Ernst de Haan Aq znerd@FreeBSD.org |