ports/www/orion-devel/files/orionctl
Maxim Sobolev e5550b640d Update that introduces extra flexibility for the installation process
and other improvements in the Makefile. It also introduces quite a few
improvements in the `orionctl' script.

PR:		27643
Submitted by:	maintainer
2001-05-29 12:54:13 +00:00

103 lines
2.3 KiB
Bash

#!/bin/sh
# Set some more variables
NAME=%%PORTNAME%%
VERSION=%%PORTVERSION%%
ORION_HOME=%%ORION_HOME%%
LOG=${ORION_HOME}/log/${NAME}.log
PID_FILE=/var/run/${NAME}.pid
JAR_FILE=${ORION_HOME}/${NAME}.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
# 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
JAVA_CMD=${JAVA_HOME}/bin/java
case "$1" in
start)
# Make sure Orion is not started previously
if [ -e ${PID_FILE} ]; then
if [ "${AS_RC_SCRIPT}" = "yes" ]; then
echo ""
fi
echo "${NAME}: ERROR: Orion has already been started."
echo "${NAME}: ERROR: Found Orion PID file at ${PID_FILE}. Orion is probably already running."
exit 64
fi
# Make sure the Orion directory does exist
if [ ! -d ${ORION_HOME} ]; then
if [ "${AS_RC_SCRIPT}" = "yes" ]; then
echo ""
fi
echo "${NAME}: ERROR: Unable to find Orion home directory at ${ORION_HOME}."
exit 64
fi
# Make sure the Orion JAR file exists
if [ ! -r ${JAR_FILE} ]; then
if [ "${AS_RC_SCRIPT}" = "yes" ]; then
echo ""
fi
echo "${NAME}: ERROR: Unable to find Orion JAR file at ${JAR_FILE}."
exit 64
fi
# Make sure the Java VM can be found
if [ ! -x ${JAVA_CMD} ]; then
if [ "${AS_RC_SCRIPT}" = "yes" ]; then
echo ""
fi
echo "${NAME}: ERROR: Unable to find Java VM at ${JAVA_HOME}."
exit 64
fi
# Create the process ID file
rm -f ${PID_FILE}
touch ${PID_FILE}
chown root:wheel ${PID_FILE}
chmod 600 ${PID_FILE}
if [ "${AS_RC_SCRIPT}" = "yes" ]; then
echo -n " ${NAME}"
fi
( cd ${ORION_HOME} && ${JAVA_CMD} -jar orion.jar & echo $! > ${PID_FILE} ) > ${LOG} 2>&1
;;
stop)
if [ ! -e ${PID_FILE} ]; then
# If run as an rc script, die silently...
if [ "${AS_RC_SCRIPT}" = "yes" ]; then
exit 0
# ...otherwise complain
else
echo "${NAME}: ERROR: Unable to find Orion PID file at ${PID_FILE}. Orion is probably not running."
exit 64
fi
else
if [ "${AS_RC_SCRIPT}" = "yes" ]; then
echo -n " ${NAME}"
fi
/bin/kill `cat ${PID_FILE}`
rm ${PID_FILE}
fi
;;
*)
echo ""
echo "Usage: ${MYSELF} { start | stop }"
echo ""
exit 64
;;
esac