amq-broker-helm/artemis-broker/scripts-override/configure_custom_config.sh
Marko Oldenburg e4c7b319e2
All checks were successful
Build Helm Chart / helm-package (push) Successful in 7s
first commit
2025-03-04 07:05:50 +01:00

38 lines
880 B
Bash
Executable File

#!/bin/bash
set -e
INSTANCE_DIR=$1
declare -a CONFIG_FILES=("bootstrap.xml" "broker.xml" "logging.properties")
function swapVars() {
# Requires bash v4+
declare -A SUBSTITUTIONS
while read -r SUBVAR
do
SUBSTITUTIONS[$SUBVAR]=1
done < <( awk '{
while( match($0, /\$\{[a-zA-Z_0-9][a-zA-Z_0-9]*\}/) ) {
print substr($0, RSTART, RLENGTH)
sub(/\$\{[a-zA-Z_0-9][a-zA-Z_0-9]*\}/, "matched", $0)
}
}' $1 )
echo "Found placeholder variables: \"${!SUBSTITUTIONS[@]}\". Customizing configuration.."
for var in "${!SUBSTITUTIONS[@]}"; do
sed -i "s#$var#$(eval echo \"$var\")#g" $1
done
}
for config_file in ${CONFIG_FILES[@]};
do
# Swap env vars into configuration file
if [[ -e $INSTANCE_DIR/etc/$config_file ]]; then
echo "Patching Custom Configuration file '$config_file'"
swapVars $INSTANCE_DIR/etc/$config_file
fi
done