You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
911 B

  1. #!/bin/bash
  2. COMPOSE_VERSION=$(docker-compose --version)
  3. DOCKER_VERSION=$(docker --version)
  4. # Start the docker compose file
  5. echo "Running docker compose up. Docker version $DOCKER_VERSION. Compose version $COMPOSE_VERSION. "
  6. docker-compose up -d
  7. if [ "$?" == "1" ]; then
  8. echo "Failed to start docker images."
  9. exit 1
  10. fi
  11. # List of topics to create in container
  12. topics=(
  13. "test"
  14. "test2"
  15. "test3"
  16. "test4"
  17. "test5"
  18. "test6"
  19. )
  20. # Run docker-compose exec to make them
  21. for topic in "${topics[@]}"
  22. do
  23. echo "Making topic $topic"
  24. until docker-compose exec kafka \
  25. kafka-topics --create --topic $topic --partitions 1 --replication-factor 1 --if-not-exists --zookeeper zookeeper:2181
  26. do
  27. topic_result="$?"
  28. if [ "$topic_result" == "1" ]; then
  29. echo "Bad status code: $topic_result. Trying again."
  30. else
  31. # If it is some unknown status code, die.
  32. exit 1
  33. fi
  34. done
  35. done