I've modified the one in www.orionsupport.com.

Try it. You need to modify the first vars to match your system.

Here it goes.

#!/bin/sh
#
# Init script for Orion Server
#
# chkconfig: 345 87 13
# description: Servidor de aplicaciones J2EE
#
# Source function library.
. /etc/rc.d/init.d/functions

# Paths
JAVA_HOME=/usr/local/jdk1.3
ORION_HOME=/usr/local/orion

# Enable /etc/rc.d/init.d/functions style color
COLOR=true

# Orion RMI administrator settings
ADMIN_USER=admin
ADMIN_PASSWORD=123
ADMIN_ORMI=ormi://localhost

## INICIALIZACION

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

## DEFINICION DE FUNCIONES

## 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 [ "$UID" != "0" ]; then
                echoresult FAILED "Only user root 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 <<EOF
Usage: $0 {start|stop|kill|restart|reload|status|update|help}

        start   : Start server
        stop    : Stop server normally
        kill    : Terminate server (kill -9)
        restart : Stop (or terminate) server and restart
        reload  : Reload server 
        status  : Check status of server
        update  : Auto-update server to latest version
        help    : ermmm..

EOF

}

case "$1" in

        'start')
                startorion
        ;;
        
        'stop')
                stoporion
        ;;

        'reload')
                reloadorion
        ;;

        'kill')
                killorion
        ;;

        'restart')
                killorion
                startorion
        ;;      

        'status')
                OP=`orionpid`
                if [ $OP = "0" ] ; then
                        echo "orion is stopped"
                        exit 1
                else
                        echo "orion (pid $OP) is running..."
                        exit 0
                fi
        ;;

        'help'|'-help'|'--help'|'h'|'-h'|'?'|'-?')
                showhelp
                exit 1
        ;;

        'update')
                killorion
                cd $ORION_HOME
                $JAVA_HOME/bin/java -jar autoupdate.jar
                startorion
        ;;

        *)
                echo "Usage: $0 {start|stop|kill|restart|reload|status|update|help}"
                exit 1
        ;;
        
esac

exit $?


-- 
-----------------------------------------------------------------
Sergi Baila      <[EMAIL PROTECTED]>          www.imaginart.es
Area de Internet                    imaginArt Master Distributor
Via Augusta, 99 08006 Barcelona SPAIN
tel: +34 93.2920770     fax: +34 93.2177651
-----------------------------------------------------------------

Reply via email to