compose-utils.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/bash
  2. #
  3. # Copyright © 2016-2022 The Thingsboard Authors
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. function additionalComposeArgs() {
  18. source .env
  19. ADDITIONAL_COMPOSE_ARGS=""
  20. case $DATABASE in
  21. postgres)
  22. ADDITIONAL_COMPOSE_ARGS="-f docker-compose.postgres.yml"
  23. ;;
  24. hybrid)
  25. ADDITIONAL_COMPOSE_ARGS="-f docker-compose.hybrid.yml"
  26. ;;
  27. *)
  28. echo "Unknown DATABASE value specified: '${DATABASE}'. Should be either postgres or hybrid." >&2
  29. exit 1
  30. esac
  31. echo $ADDITIONAL_COMPOSE_ARGS
  32. }
  33. function additionalComposeQueueArgs() {
  34. source .env
  35. ADDITIONAL_COMPOSE_QUEUE_ARGS=""
  36. case $TB_QUEUE_TYPE in
  37. kafka)
  38. ADDITIONAL_COMPOSE_QUEUE_ARGS="-f docker-compose.kafka.yml"
  39. ;;
  40. confluent)
  41. ADDITIONAL_COMPOSE_QUEUE_ARGS="-f docker-compose.confluent.yml"
  42. ;;
  43. aws-sqs)
  44. ADDITIONAL_COMPOSE_QUEUE_ARGS="-f docker-compose.aws-sqs.yml"
  45. ;;
  46. pubsub)
  47. ADDITIONAL_COMPOSE_QUEUE_ARGS="-f docker-compose.pubsub.yml"
  48. ;;
  49. rabbitmq)
  50. ADDITIONAL_COMPOSE_QUEUE_ARGS="-f docker-compose.rabbitmq.yml"
  51. ;;
  52. service-bus)
  53. ADDITIONAL_COMPOSE_QUEUE_ARGS="-f docker-compose.service-bus.yml"
  54. ;;
  55. *)
  56. echo "Unknown Queue service value specified: '${TB_QUEUE_TYPE}'. Should be either kafka or confluent or aws-sqs or pubsub or rabbitmq or service-bus." >&2
  57. exit 1
  58. esac
  59. echo $ADDITIONAL_COMPOSE_QUEUE_ARGS
  60. }
  61. function additionalComposeMonitoringArgs() {
  62. source .env
  63. if [ "$MONITORING_ENABLED" = true ]
  64. then
  65. ADDITIONAL_COMPOSE_MONITORING_ARGS="-f docker-compose.prometheus-grafana.yml"
  66. echo $ADDITIONAL_COMPOSE_MONITORING_ARGS
  67. else
  68. echo ""
  69. fi
  70. }
  71. function additionalStartupServices() {
  72. source .env
  73. ADDITIONAL_STARTUP_SERVICES=""
  74. case $DATABASE in
  75. postgres)
  76. ADDITIONAL_STARTUP_SERVICES=postgres
  77. ;;
  78. hybrid)
  79. ADDITIONAL_STARTUP_SERVICES="postgres cassandra"
  80. ;;
  81. *)
  82. echo "Unknown DATABASE value specified: '${DATABASE}'. Should be either postgres or hybrid." >&2
  83. exit 1
  84. esac
  85. echo $ADDITIONAL_STARTUP_SERVICES
  86. }