#!/bin/sh # # orion: Orion Application Server # # description: Orion is an enterprise level J2EE application \ # server. www.orionserver.com # # This script comes with no guarantees of anything. # Check www.orionsupport.com for latest version. # Joe Walnes - joe at truemesh.com # Paths JAVA_HOME=/usr/local/java ORION_HOME=/opt/orion # *nix user orion should run as ORION_USER=orion # Orion RMI administrator settings ADMIN_USER=admin ADMIN_PASSWORD=123 ADMIN_ORMI=ormi://localhost # Enable /etc/rc.d/init.d/functions style color COLOR=true #################################################################### # Do not edit anything below this, unless you want to of course :) # #################################################################### if [ "$COLOR" = "true" ]; then RES_COL=60 MOVE_TO_COL="echo -en \\033[${RES_COL}G" SETCOLOR_SUCCESS="echo -en \\033[1;32m" SETCOLOR_FAILURE="echo -en \\033[1;31m" SETCOLOR_WARNING="echo -en \\033[1;33m" SETCOLOR_NORMAL="echo -en \\033[0;39m" else MOVE_TO_COL="" SETCOLOR_SUCCESS="" SETCOLOR_FAILURE="" SETCOLOR_WARNING="" SETCOLOR_NORMAL="" fi ## Execute admin.jar orionadmin() { echo `\ cd $ORION_HOME && \ $JAVA_HOME/bin/java \ -jar $ORION_HOME/admin.jar \ $ADMIN_ORMI $ADMIN_USER $ADMIN_PASSWORD \ $@ \ 2>&1` } ## Echo PID of Orion (or 0 if not running) orionpid() { if [ -f $ORION_HOME/orion.pid ]; then if [ -n "`cat $ORION_HOME/orion.pid | xargs ps -h`" ]; then cat $ORION_HOME/orion.pid return fi fi echo -n 0 } ## Start Orion startorion() { echo -n "Starting Orion Application Server:" if [ "$USER" != "$ORION_USER" ]; then echoresult FAILED "Only users root or $ORION_USER should start the server" return 1 fi if [ "`orionpid`" != "0" ]; then echoresult FAILED "An instance of Orion is already running" return 1 fi ## All clear cd $ORION_HOME umask 007 $JAVA_HOME/bin/java \ -jar orion.jar \ -config $ORION_HOME/config/server.xml \ -out $ORION_HOME/log/server-out.log \ -err $ORION_HOME/log/server-err.log \ & echo -n $! > $ORION_HOME/orion.pid echoresult OK return 0 } stoporion() { admincontrol "-shutdown" "Stopping Orion Application Server:" } reloadorion() { admincontrol "-restart" "Reloading Orion Application Server:" } killorion() { echo -n "Killing Orion Application Server:" OP=`orionpid` if [ $OP != "0" ]; then kill -9 $OP echoresult OK return 0 else echoresult FAILED "Cannot determine Orion pid" return 1 fi } stopkillorion() { stoporion if [ "$?" != "0" ]; then killorion fi } admincontrol() { echo -n "$2" OA=`orionadmin $1` if [ -z "$OA" ]; then echoresult OK else CR=`echo "$OA" | grep "Connection refused"` if [ -n "$CR" ]; then echoresult FAILED "No instance of Orion is running" else echoresult FAILED "$OA" fi return 1 fi } ## Echo result message echoresult() { echo -n " " $MOVE_TO_COL echo -n "[ " case "$1" in 'OK') $SETCOLOR_SUCCESS ;; 'FAILED') $SETCOLOR_FAILURE ;; *) $SETCOLOR_WARNING ;; esac echo -n $1 $SETCOLOR_NORMAL echo " ]" shift if [ "$#" != "0" ] ; then echo "$1" ; fi } ## Show help message showhelp() { cat <