if [[ -z "$KAFKA_BOOTSTRAP_SERVERS" ]]; then echo "ERROR: missing mandatory config: KAFKA_BOOTSTRAP_SERVERS" exit 1 fi
if [[ -z "$KAFK_GROUP_ID" ]]; then export KAFK_GROUP_ID=mm2 fi
( function updateConfig() { key=$1 value=$2 file=$3
# Omit $value here, in case there is sensitive information echo "[Configuring] '$key' in '$file'"
# If config exists in file, replace it. Otherwise, append to file. if grep -E -q "^#?$key=" "$file"; then sed -r -i "s@^#?$key=.*@$key=$value@g" "$file" #note that no config values may contain an '@' char else echo "$key=$value" >> "$file" fi }
for VAR in $(env) do env_var=$(echo "$VAR" | cut -d= -f1) if [[ "$EXCLUSIONS" = *"|$env_var|"* ]]; then echo "Excluding $env_var from broker config" continue fi
if [[ $env_var =~ ^KAFKA_ ]]; then kafka_name=$(echo "$env_var" | cut -d_ -f2- | tr '[:upper:]' '[:lower:]' | tr _ .) updateConfig "$kafka_name" "${!env_var}" "$CONFIG_FILE" fi done
if [[ "$KAFKA_SASL_ENABLE" = "true" ]]; then if [ ! KAFKA_ADMIN_PASSWORD ]; then KAFKA_ADMIN_PASSWORD=123456 fi