artnaseef commented on code in PR #2791:
URL: https://github.com/apache/activemq/pull/2791#discussion_r4484224346
##########
assembly/src/docker/entrypoint.sh:
##########
@@ -26,20 +29,16 @@ if [ -n "${ACTIVEMQ_CONNECTION_USER}" ]; then
echo "Enabling ActiveMQ Connection Security"
sed -i
"s/activemq.username=system/activemq.username=${ACTIVEMQ_CONNECTION_USER}/"
${ACTIVEMQ_HOME}/conf/credentials.properties
sed -i
"s/activemq.password=manager/activemq.password=${ACTIVEMQ_CONNECTION_PASSWORD}/"
${ACTIVEMQ_HOME}/conf/credentials.properties
- read -r -d '' REPLACE << END
+ IFS= read -r -d '' REPLACE <<"END" || true
<plugins>
<simpleAuthenticationPlugin>
<users>
- <authenticationUser username="$\{activemq.username}"
password="$\{activemq.password}"/>
+ <authenticationUser username="${activemq.username}"
password="${activemq.password}"/>
</users>
</simpleAuthenticationPlugin>
</plugins>
- </broker>
END
- REPLACE=${REPLACE//$\\/$}
- REPLACE=${REPLACE//\//\\\/}
- REPLACE=$(echo $REPLACE | tr '\n' ' ')
- sed -i "s/<\/broker>/$REPLACE/" ${ACTIVEMQ_HOME}/conf/activemq.xml
+ sed -i "s,</broker>,${REPLACE//$'\n'/\\n}&,"
${ACTIVEMQ_HOME}/conf/activemq.xml
Review Comment:
Here's a simple awk 1-liner that eliminates all of the quoting concerns:
`awk -v REPLACEMENT="${REPLACE}" '/<\/broker>/ { print REPLACEMENT; } {
print; }'`
No `-i` equivalent for sed, so the full alternative would be something like
this:
awk -v REPLACEMENT="${REPLACE}" '/<\/broker>/ { print REPLACEMENT; } {
print; } "${ACTIVEMQ_HOME}/conf/activemq.xml"
>"${ACTIVEMQ_HOME}/conf/activemq.xml.upd"
mv "${ACTIVEMQ_HOME}/conf/activemq.xml.upd"
"${ACTIVEMQ_HOME}/conf/activemq.xml"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact