From 3f6ffd30d27d3ac3c11d27004eea850fa165c0b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Baptiste=20Onofr=C3=A9?= Date: Mon, 28 Nov 2022 18:41:55 +0100 Subject: [PATCH] [AMQ-9126] Set jolokia.conf sys prop and escape cleanly on Windows platform (cherry picked from commit 49626f07b67c09914d4b70548da6e198bd0de1e0) --- assembly/src/release/bin/activemq | 13 +++++++++++++ assembly/src/release/bin/activemq.bat | 6 +++++- assembly/src/release/webapps/api/WEB-INF/web.xml | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/assembly/src/release/bin/activemq b/assembly/src/release/bin/activemq index c3f04f2e5f..422cbd8d0f 100755 --- a/assembly/src/release/bin/activemq +++ b/assembly/src/release/bin/activemq @@ -125,6 +125,11 @@ if [ -z "$ACTIVEMQ_CONF" ] ; then fi fi +# Jolokia configuration +if [ -z "$JOLOKIA_CONF" ] ; then + JOLOKIA_CONF=file:$ACTIVEMQ_CONF/jolokia-access.xml +fi + # Configure a user with non root privileges, if no user is specified do not change user if [ -z "$ACTIVEMQ_USER" ] ; then ACTIVEMQ_USER="" @@ -267,6 +272,7 @@ if [ "$OSTYPE" = "cygwin" ];then ACTIVEMQ_BASE="`cygpath --windows "$ACTIVEMQ_BASE"`" ACTIVEMQ_CONF="`cygpath --windows "$ACTIVEMQ_CONF"`" ACTIVEMQ_DATA="`cygpath --windows "$ACTIVEMQ_DATA"`" + JOLOKIA_CONF="`cygpath --windows "$JOLOKIA_CONF"`" ACTIVEMQ_CLASSPATH=`cygpath --path --windows "$ACTIVEMQ_CLASSPATH"` [ -n "$JAVA_HOME" ] && JAVA_HOME="`cygpath --windows "$JAVA_HOME"`" @@ -288,6 +294,7 @@ if [ "$OSTYPE" = "cygwin" ];then ACTIVEMQ_BASE="`echo ${ACTIVEMQ_BASE}|sed '~s,[\\]*$,,g'`" ACTIVEMQ_CONF="`echo ${ACTIVEMQ_CONF}|sed '~s,[\\]*$,,g'`" ACTIVEMQ_DATA="`echo ${ACTIVEMQ_DATA}|sed '~s,[\\]*$,,g'`" + JOLOKIA_CONF="`echo ${JOLOKIA_CONF}|sed '~s,[\\]*$,,g'`" fi # Start the ActiveMQ JAR @@ -361,6 +368,7 @@ invokeJar(){ -Dactivemq.base=\"${ACTIVEMQ_BASE}\" \ -Dactivemq.conf=\"${ACTIVEMQ_CONF}\" \ -Dactivemq.data=\"${ACTIVEMQ_DATA}\" \ + -Djolokia.conf=\"${JOLOKIA_CONF}\" \ $ACTIVEMQ_CYGWIN \ -jar \"${ACTIVEMQ_HOME}/bin/activemq.jar\" $COMMANDLINE_ARGS >> $ACTIVEMQ_OUT 2>&1 & RET=\"\$?\"; APID=\"\$!\"; @@ -374,6 +382,7 @@ invokeJar(){ -Dactivemq.base=\"${ACTIVEMQ_BASE}\" \ -Dactivemq.conf=\"${ACTIVEMQ_CONF}\" \ -Dactivemq.data=\"${ACTIVEMQ_DATA}\" \ + -Djolokia.conf=\"${JOLOKIA_CONF}\" \ $ACTIVEMQ_CYGWIN \ -jar \"${ACTIVEMQ_HOME}/bin/activemq.jar\" $COMMANDLINE_ARGS >> $ACTIVEMQ_OUT 2>&1 & RET=\"\$?\"; APID=\"\$!\"; @@ -404,6 +413,7 @@ invokeJar(){ -Dactivemq.base=\"${ACTIVEMQ_BASE}\" \ -Dactivemq.conf=\"${ACTIVEMQ_CONF}\" \ -Dactivemq.data=\"${ACTIVEMQ_DATA}\" \ + -Djolokia.conf=\"${JOLOKIA_CONF}\" \ $ACTIVEMQ_CYGWIN \ -jar \"${ACTIVEMQ_HOME}/bin/activemq.jar\" $COMMANDLINE_ARGS --pid $SPID & RET=\"\$?\"; APID=\"\$!\"; @@ -416,6 +426,7 @@ invokeJar(){ -Dactivemq.base=\"${ACTIVEMQ_BASE}\" \ -Dactivemq.conf=\"${ACTIVEMQ_CONF}\" \ -Dactivemq.data=\"${ACTIVEMQ_DATA}\" \ + -Djolokia.conf=\"${JOLOKIA_CONF}\" \ $ACTIVEMQ_CYGWIN \ -jar \"${ACTIVEMQ_HOME}/bin/activemq.jar\" $COMMANDLINE_ARGS --pid $SPID & RET=\"\$?\"; APID=\"\$!\"; @@ -444,6 +455,7 @@ invokeJar(){ -Dactivemq.base=\"${ACTIVEMQ_BASE}\" \ -Dactivemq.conf=\"${ACTIVEMQ_CONF}\" \ -Dactivemq.data=\"${ACTIVEMQ_DATA}\" \ + -Djolokia.conf=\"${JOLOKIA_CONF}\" \ $ACTIVEMQ_CYGWIN \ -jar \"${ACTIVEMQ_HOME}/bin/activemq.jar\" $COMMANDLINE_ARGS" $DOIT_POSTFIX RET="$?" @@ -454,6 +466,7 @@ invokeJar(){ -Dactivemq.base=\"${ACTIVEMQ_BASE}\" \ -Dactivemq.conf=\"${ACTIVEMQ_CONF}\" \ -Dactivemq.data=\"${ACTIVEMQ_DATA}\" \ + -Djolokia.conf=\"${JOLOKIA_CONF}\" \ $ACTIVEMQ_CYGWIN \ -jar \"${ACTIVEMQ_HOME}/bin/activemq.jar\" $COMMANDLINE_ARGS" $DOIT_POSTFIX RET="$?" diff --git a/assembly/src/release/bin/activemq.bat b/assembly/src/release/bin/activemq.bat index c532c43aea..831b7f30b9 100755 --- a/assembly/src/release/bin/activemq.bat +++ b/assembly/src/release/bin/activemq.bat @@ -92,7 +92,11 @@ REM Setup ActiveMQ Classpath. REM Add instance conf dir before AMQ install conf dir to pick up instance-specific classpath entries first set ACTIVEMQ_CLASSPATH=%ACTIVEMQ_CONF%;%ACTIVEMQ_BASE%/conf;%ACTIVEMQ_HOME%/conf;%ACTIVEMQ_CLASSPATH% -"%_JAVACMD%" %ACTIVEMQ_SUNJMX_START% %ACTIVEMQ_DEBUG_OPTS% %ACTIVEMQ_OPTS% %ACTIVEMQ_SSL_OPTS% -Dactivemq.classpath="%ACTIVEMQ_CLASSPATH%" -Dactivemq.home="%ACTIVEMQ_HOME%" -Dactivemq.base="%ACTIVEMQ_BASE%" -Dactivemq.conf="%ACTIVEMQ_CONF%" -Dactivemq.data="%ACTIVEMQ_DATA%" -Djava.io.tmpdir="%ACTIVEMQ_TMP%" -jar "%ACTIVEMQ_HOME%/bin/activemq.jar" %* +REM Setup jolokia-access.xml path by doubling the \\ +if "%JOLOKIA_CONF%" == "" set JOLOKIA_CONF=file:%ACTIVEMQ_CONF%\jolokia-access.xml +set JOLOKIA_CONF=%JOLOKIA_CONF:\=\\% + +"%_JAVACMD%" %ACTIVEMQ_SUNJMX_START% %ACTIVEMQ_DEBUG_OPTS% %ACTIVEMQ_OPTS% %ACTIVEMQ_SSL_OPTS% -Dactivemq.classpath="%ACTIVEMQ_CLASSPATH%" -Dactivemq.home="%ACTIVEMQ_HOME%" -Dactivemq.base="%ACTIVEMQ_BASE%" -Dactivemq.conf="%ACTIVEMQ_CONF%" -Dactivemq.data="%ACTIVEMQ_DATA%" -Djolokia.conf="%JOLOKIA_CONF%" -Djava.io.tmpdir="%ACTIVEMQ_TMP%" -jar "%ACTIVEMQ_HOME%/bin/activemq.jar" %* goto end diff --git a/assembly/src/release/webapps/api/WEB-INF/web.xml b/assembly/src/release/webapps/api/WEB-INF/web.xml index 56825838c3..e7013186fe 100644 --- a/assembly/src/release/webapps/api/WEB-INF/web.xml +++ b/assembly/src/release/webapps/api/WEB-INF/web.xml @@ -55,7 +55,7 @@ --> policyLocation - file:${prop:activemq.conf}/jolokia-access.xml + ${prop:jolokia.conf}