modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.sh | 101 +++++++---
1 file changed, 76 insertions(+), 25 deletions(-)
New commits:
commit b39684227421d5a09fe0ab5d0b932d45179fefc2
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Nov 30 15:39:20 2012 -0500
all a user to point to an external JBossAS installation via JBOSS_HOME or RHQ_SERVER_JBOSS_HOME
diff --git a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.sh b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.sh
index dc93347..e917230 100644
--- a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.sh
+++ b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.sh
@@ -25,6 +25,13 @@
# If not defined, it will be assumed to be the parent
# directory of the directory where this script lives.
#
+# RHQ_SERVER_JBOSS_HOME - The location of the AS instance that will
+# host RHQ. If this is set, it overrides any
+# JBOSS_HOME that might be set. If this not
+# set, JBOSS_HOME is used as a fallback. If
+# neither is set, it is assumed the AS bundled
+# under RHQ_SERVER_HOME/jbossas is to be used.
+#
# RHQ_SERVER_JAVA_HOME - The location of the JRE that the server will
# use. This will be ignored if
# RHQ_SERVER_JAVA_EXE_FILE_PATH is set.
@@ -107,17 +114,6 @@
#export LD_LIBRARY_PATH="$JPROFILER_HOME/bin/linux-x64"
# ----------------------------------------------------------------------
-# Make sure we unset any lingering JBossAS environment variables that
-# were set in the user's environment. This might happen if the user
-# has an external JBossAS configured.
-# ----------------------------------------------------------------------
-
-unset JBOSS_HOME
-unset RUN_CONF
-unset JAVAC_JAR
-unset JBOSS_CLASSPATH
-
-# ----------------------------------------------------------------------
# Dumps a message iff debug mode is enabled
# ----------------------------------------------------------------------
@@ -182,6 +178,22 @@ remove_pid_files ()
}
# ----------------------------------------------------------------------
+# Unset any lingering JBossAS environment variables that were set in
+# the user's environment. This might happen if the user has an external
+# JBossAS installed and configured but doesn't want RHQ to use it.
+# ----------------------------------------------------------------------
+unset_jboss_as_env ()
+{
+ unset JBOSS_HOME
+ unset RUN_CONF
+ unset JAVAC_JAR
+ unset JBOSS_CLASSPATH
+ unset JBOSS_BASE_DIR
+ unset JBOSS_LOG_DIR
+ unset JBOSS_CONFIG_DIR
+}
+
+# ----------------------------------------------------------------------
# Determine what specific platform we are running on.
# Set some platform-specific variables.
# ----------------------------------------------------------------------
@@ -199,6 +211,11 @@ case "`uname`" in
;;
esac
+# only certain platforms support the -e argument for readlink
+if [ -n "${_LINUX}${_SOLARIS}${_CYGWIN}" ]; then
+ _READLINK_ARG="-e"
+fi
+
# ----------------------------------------------------------------------
# Determine the RHQ Server installation directory.
# If RHQ_SERVER_HOME is not defined, we will assume we are running
@@ -206,10 +223,6 @@ esac
# ----------------------------------------------------------------------
if [ -z "$RHQ_SERVER_HOME" ]; then
- if [ -n "${_LINUX}${_SOLARIS}${_CYGWIN}" ]; then
- # only certain platforms support the -e argument for readlink
- _READLINK_ARG="-e"
- fi
_DOLLARZERO=`readlink $_READLINK_ARG "$0" 2>/dev/null || echo "$0"`
RHQ_SERVER_HOME=`dirname "$_DOLLARZERO"`/..
else
@@ -225,9 +238,45 @@ RHQ_SERVER_HOME=`pwd`
debug_msg "RHQ_SERVER_HOME: $RHQ_SERVER_HOME"
-if [ ! -f "${RHQ_SERVER_HOME}/jbossas/jboss-modules.jar" ]; then
- echo "ERROR! RHQ_SERVER_HOME is not pointing to a valid RHQ Server"
- echo "Missing ${RHQ_SERVER_HOME}/jbossas/jboss-modules.jar"
+# ----------------------------------------------------------------------
+# Determine what JBossAS instance to use.
+# If RHQ_SERVER_JBOSS_HOME and JBOSS_HOME are both not defined, we will
+# assume we are to run the embedded AS instance from the RHQ
+# installation directory - RHQ_SERVER_HOME/jbossas
+# ----------------------------------------------------------------------
+
+if [ -z "$RHQ_SERVER_JBOSS_HOME" ]; then
+ if [ -z "$JBOSS_HOME" ]; then
+ RHQ_SERVER_JBOSS_HOME="${RHQ_SERVER_HOME}/jbossas"
+ # Unset any lingering JBossAS environment variables that we don't want.
+ # These could be in the user's environment for an external AS install.
+ unset_jboss_as_env
+ else
+ if [ ! -d "$JBOSS_HOME" ]; then
+ echo "ERROR! JBOSS_HOME is not pointing to a valid AS directory"
+ echo "JBOSS_HOME: $JBOSS_HOME"
+ exit 1
+ fi
+ RHQ_SERVER_JBOSS_HOME="${JBOSS_HOME}"
+ fi
+else
+ if [ ! -d "$RHQ_SERVER_JBOSS_HOME" ]; then
+ echo "ERROR! RHQ_SERVER_JBOSS_HOME is not pointing to a valid AS directory"
+ echo "RHQ_SERVER_JBOSS_HOME: $RHQ_SERVER_JBOSS_HOME"
+ exit 1
+ fi
+ unset_jboss_as_env
+fi
+
+cd "$RHQ_SERVER_JBOSS_HOME"
+RHQ_SERVER_JBOSS_HOME=`pwd`
+
+debug_msg "RHQ_SERVER_JBOSS_HOME: $RHQ_SERVER_JBOSS_HOME"
+
+
+if [ ! -f "${RHQ_SERVER_JBOSS_HOME}/jboss-modules.jar" ]; then
+ echo "ERROR! RHQ_SERVER_JBOSS_HOME is not pointing to a valid RHQ Server"
+ echo "Missing ${RHQ_SERVER_JBOSS_HOME}/jboss-modules.jar"
exit 1
fi
@@ -242,7 +291,10 @@ if [ -z "$JAVA_HOME" ]; then
fi
fi
+# ----------------------------------------------------------------------
# create the logs directory
+# ----------------------------------------------------------------------
+
_LOG_DIR_PATH="${RHQ_SERVER_HOME}/logs"
if [ -n "$_CYGWIN" ]; then
_LOG_DIR_PATH=`cygpath --windows --path "$_LOG_DIR_PATH"`
@@ -335,7 +387,7 @@ _CMDLINE_OPTS="$RHQ_SERVER_CMDLINE_OPTS $RHQ_SERVER_ADDITIONAL_CMDLINE_OPTS"
# JBOSS_MODULEPATH tells standalone.sh what to use.
# ----------------------------------------------------------------------
_RHQ_MODULES_PATH="${RHQ_SERVER_HOME}/modules"
-_INTERNAL_MODULES_PATH="${RHQ_SERVER_HOME}/jbossas/modules"
+_INTERNAL_MODULES_PATH="${RHQ_SERVER_JBOSS_HOME}/modules"
if [ -n "$_CYGWIN" ]; then
_RHQ_MODULES_PATH=`cygpath --windows --path "$_RHQ_MODULES_PATH"`
_INTERNAL_MODULES_PATH=`cygpath --windows --path "$_INTERNAL_MODULES_PATH"`
@@ -348,7 +400,7 @@ debug_msg "JBOSS_MODULEPATH: $JBOSS_MODULEPATH"
# Now find the JBossAS standalone.sh script
# ----------------------------------------------------------------------
-_JBOSS_RUN_SCRIPT="${RHQ_SERVER_HOME}/jbossas/bin/standalone.sh"
+_JBOSS_RUN_SCRIPT="${RHQ_SERVER_JBOSS_HOME}/bin/standalone.sh"
if [ ! -f "$_JBOSS_RUN_SCRIPT" ]; then
echo "ERROR! Cannot find the JBossAS run script"
@@ -392,7 +444,7 @@ case "$1" in
echo "$$" > "$_JVM_PIDFILE"
# start the server, making sure its working directory is the JBossAS bin directory
- cd "${RHQ_SERVER_HOME}/jbossas/bin"
+ cd "${RHQ_SERVER_JBOSS_HOME}/bin"
"$_JBOSS_RUN_SCRIPT" $_CMDLINE_OPTS
_JBOSS_STATUS=$?
@@ -416,7 +468,7 @@ case "$1" in
export JBOSS_PIDFILE
# start the server, making sure its working directory is the JBossAS bin directory
- cd "${RHQ_SERVER_HOME}/jbossas/bin"
+ cd "${RHQ_SERVER_JBOSS_HOME}/bin"
if [ -n "$RHQ_SERVER_DEBUG" ] && [ "$RHQ_SERVER_DEBUG" != "false" ]; then
"$_JBOSS_RUN_SCRIPT" $_CMDLINE_OPTS &
else
@@ -498,8 +550,8 @@ case "$1" in
fi
echo "Cleaning data, tmp and log directories..."
- rm -rf "${RHQ_SERVER_HOME}/jbossas/standalone/data"
- rm -rf "${RHQ_SERVER_HOME}/jbossas/standalone/tmp"
+ rm -rf "${RHQ_SERVER_JBOSS_HOME}/standalone/data"
+ rm -rf "${RHQ_SERVER_JBOSS_HOME}/standalone/tmp"
rm -rf "${RHQ_SERVER_HOME}/logs"
;;
@@ -514,4 +566,3 @@ case "$1" in
exit 1
;;
esac
-