entrypoint.sh 957 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. set -eu
  3. set -o pipefail
  4. KAFKA_VERSION="${KAFKA_VERSION:-3.6.0}"
  5. KAFKA_HOME="/opt/kafka-${KAFKA_VERSION}"
  6. if [ ! -d "${KAFKA_HOME}" ]; then
  7. echo 'Error: KAFKA_VERSION '$KAFKA_VERSION' not available in this image at '$KAFKA_HOME
  8. exit 1
  9. fi
  10. cd "${KAFKA_HOME}" || exit 1
  11. # discard all empty/commented lines from default config and copy to /tmp
  12. sed -e '/^#/d' -e '/^$/d' config/server.properties >/tmp/server.properties
  13. echo "########################################################################" >>/tmp/server.properties
  14. # emulate kafka_configure_from_environment_variables from bitnami/bitnami-docker-kafka
  15. for var in "${!KAFKA_CFG_@}"; do
  16. key="$(echo "$var" | sed -e 's/^KAFKA_CFG_//g' -e 's/_/\./g' -e 's/.*/\L&/')"
  17. sed -e '/^'$key'/d' -i"" /tmp/server.properties
  18. value="${!var}"
  19. echo "$key=$value" >>/tmp/server.properties
  20. done
  21. sort /tmp/server.properties
  22. exec bin/kafka-server-start.sh /tmp/server.properties