diff options
Diffstat (limited to 'java/orion/files/orionctl')
-rw-r--r-- | java/orion/files/orionctl | 80 |
1 files changed, 57 insertions, 23 deletions
diff --git a/java/orion/files/orionctl b/java/orion/files/orionctl index 040da2d..cd4b252 100644 --- a/java/orion/files/orionctl +++ b/java/orion/files/orionctl @@ -1,68 +1,102 @@ #!/bin/sh -if [ "${LOCALBASE}a" = "a" ]; then - LOCALBASE=/usr/local -fi +# 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` -NAME=orion -ORION_HOME=${LOCALBASE}/orion1.4.5 -LOG=${ORION_HOME}/log/orion.log -PID_FILE=/var/run/orion.pid -JAR_FILE=${ORION_HOME}/orion.jar +# 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=${LOCALBASE}/linux-jdk1.3.0 + JAVA_HOME=%%JAVA_HOME%% fi JAVA_CMD=${JAVA_HOME}/bin/java -# TODO: Check if we are being run at boot time right now - - 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 - echo "" + 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 - echo "" + 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 - echo "" + 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 -rf ${PID_FILE} + rm -f ${PID_FILE} touch ${PID_FILE} chown root:wheel ${PID_FILE} chmod 600 ${PID_FILE} - echo -n ' orion' + 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 - echo "" - echo "${NAME}: ERROR: Unable to find Orion PID file at ${PID_FILE}." - exit 64 + + # 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 - /bin/kill `cat ${PID_FILE}` - echo -n ' orion' ;; *) echo "" - echo "Usage: `basename $0` { start | stop }" + echo "Usage: ${MYSELF} { start | stop }" echo "" exit 64 ;; |