#!/bin/sh # # oc4j - shell for invoking OC4J basic operations. # # Usage: oc4j [Options] # # Options: # -start : start OC4J # -shutdown -port -password # : stop OC4J # -version : display the version # -help : display this message # # Copyright (c) 2004, 2005, Oracle. All rights reserved. # ######################################################### ########## START CONFIGURATION SECTION ################## ######################################################### J2EE_HOME=$ORACLE_HOME/j2ee/home #Any persistent arguments to specify at the JVM level can be set here #By default this will be read from the operating system environment if [ "$OC4J_JVM_ARGS" ] then JVMARGS=$OC4J_JVM_ARGS else JVMARGS= fi CMDARGS= if [ "$VERBOSE" ] then VERBOSE=$VERBOSE else VERBOSE=off fi ORMI_URL=ormi://localhost ORMI_USER=oc4jadmin OC4J_JAR=$J2EE_HOME/oc4j.jar ADMIN_JAR=$J2EE_HOME/admin.jar SERVER_XML=$J2EE_HOME/config/server.xml ######################################################### ########## END CONFIGURATION SECTION ################## ######################################################### check_oc4j() { EXIT=0 if [ "$JAVA_HOME" = "" ] then echo "Error: JAVA_HOME environment variable is not defined." check_msg="correct JAVA_HOME environment variable." EXIT=2 elif [ ! -x $JAVA_HOME/bin/java ] then echo "Error: Can not find java executable in $JAVA_HOME/bin." check_msg="correct java executable." EXIT=2 elif [ "$ORACLE_HOME" = "" ] then echo "Error: The ORACLE_HOME environment variable must be set before executing this script. Set this to the directory into which you unzipped oc4j_extended.zip." check_msg="correct ORACLE_HOME environment variable." EXIT=2 elif [ ! -r "$OC4J_JAR" ] then check_msg="readable $OC4J_JAR." EXIT=2 elif [ ! -w "$SERVER_XML" ] then check_msg="writable $SERVER_XML." EXIT=2 elif [ ! -r "$ADMIN_JAR" ] then check_msg="readable $ADMIN_JAR." EXIT=2 fi } echo_check_msg() { echo "Error: The command can not be run without $1" } start_oc4j() { echo "Starting OC4J from $J2EE_HOME ..." CMDARGS="-config $SERVER_XML" while [ $# -ge 1 ] do case $1 in *) echo "" echo "Error: The optoin \"$1\" was not recognized." EXIT=1 return ;; esac done if [ "$VERBOSE" = "on" ] then echo "Executing: $JAVA_HOME/bin/java $JVMARGS -jar $OC4J_JAR $CMDARGS" fi $JAVA_HOME/bin/java $JVMARGS -jar $OC4J_JAR $CMDARGS } shutdown_oc4j() { while [ $# -ge 1 ] do case $1 in -port) shift if [ "$1" = "" ] then echo "" echo "Error: You must specify the ORMI port value." EXIT=1 return else ORMI_PORT=$1 shift fi ;; -password) shift if [ "$1" = "" ] then echo "" echo "Error: You must specify the password value." EXIT=1 return else ORMI_PASSWORD=$1 shift fi ;; *) echo "" echo "Error: The option \"$1\" was not recognized." EXIT=1 return ;; esac done if [ "$ORMI_PORT" = "" ] then echo "" echo "Error: You must specify the ORMI port using the -port switch." echo " The port value can be found in $J2EE_HOME/config/rmi.xml." EXIT=1 return fi if [ "$ORMI_PASSWORD" = "" ] then echo "" echo "Error: You must specify the ORMI password using the -password switch." EXIT=1 return fi echo "Shutdown OC4J instance..." CMDARGS="$ORMI_URL:$ORMI_PORT $ORMI_USER $ORMI_PASSWORD -shutdown" if [ "$VERBOSE" = "on" ] then echo "Executing: $JAVA_HOME/bin/java $JVMARGS -jar $ADMIN_JAR $CMDARGS" fi $JAVA_HOME/bin/java $JVMARGS -jar $ADMIN_JAR $CMDARGS } version() { echo "Getting the version of OC4J instance..." CMDARGS="-version" if [ "$VERBOSE" = "on" ] then echo "Executing: $JAVA_HOME/bin/java $JVMARGS -jar $OC4J_JAR $CMDARGS" fi $JAVA_HOME/bin/java $JVMARGS -jar $OC4J_JAR $CMDARGS } help() { cat < -password : stop OC4J -version : display the version -help : display this message EOF } ######################################## ### Start main function section ### ######################################## check_oc4j if [ ! "$EXIT" -eq 0 ] then echo_check_msg "$check_msg" else if [ $# -eq 0 ] then help else # the first argument CMDARG="$1" # decrement number of arguments shift # get the rest of the command line case $CMDARG in -start) start_oc4j "$@" ;; -shutdown) shutdown_oc4j "$@" ;; -version) if [ $# -gt 0 ] ; then echo "" echo "Error: The option \"$CMDARG\" does not take any argument." EXIT=1 else version fi ;; -help) help EXIT=0 ;; *) echo "" echo "Error: The option \"$CMDARG\" was not recognized." EXIT=1 ;; esac if [ $EXIT -eq 1 ] then help fi fi fi