From 98d0e181d53827b8459f8b0b4f013ed73328b2f1 Mon Sep 17 00:00:00 2001 From: Stefan Miklosovic Date: Tue, 20 Feb 2024 19:43:58 +0100 Subject: [PATCH] Remove bashisms for mx4j tool in cassandra-env.sh /bin/sh (our shebang in bin/cassandra) does not recognize the `if` construct which is available in /bin/bash only hence if MX4J_ADDRESS or MX4J_PORT was not commented out, the script would fail to execute it. patch by Stefan Miklosovic; reviewed by Brandon Williams for CASSANDRA-19416 --- CHANGES.txt | 1 + conf/cassandra-env.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index baeb9b7f61..c02043be1a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.0.13 + * Remove bashisms for mx4j tool in cassandra-env.sh (CASSANDRA-19416) * Add new concurrent_merkle_tree_requests config property to prevent OOM during multi-range and/or multi-table repairs (CASSANDRA-19336) Merged from 3.11: Merged from 3.0: diff --git a/conf/cassandra-env.sh b/conf/cassandra-env.sh index 2e3c8c9d8b..6d7918a261 100644 --- a/conf/cassandra-env.sh +++ b/conf/cassandra-env.sh @@ -287,7 +287,7 @@ JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.password.file=/etc/cassandra/ JVM_OPTS="$JVM_OPTS -Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin" if [ "x$MX4J_ADDRESS" != "x" ]; then - if [[ "$MX4J_ADDRESS" == \-Dmx4jaddress* ]]; then + if [ "$(echo "$MX4J_ADDRESS" | grep -c "\-Dmx4jaddress")" = "1" ]; then # Backward compatible with the older style #13578 JVM_OPTS="$JVM_OPTS $MX4J_ADDRESS" else @@ -295,7 +295,7 @@ if [ "x$MX4J_ADDRESS" != "x" ]; then fi fi if [ "x$MX4J_PORT" != "x" ]; then - if [[ "$MX4J_PORT" == \-Dmx4jport* ]]; then + if [ "$(echo "$MX4J_PORT" | grep -c "\-Dmx4jport")" = "1" ]; then # Backward compatible with the older style #13578 JVM_OPTS="$JVM_OPTS $MX4J_PORT" else