run.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. PROFILE="${PROFILE:-emqx}"
  4. EMQX_ROOT="${EMQX_ROOT:-_build/$PROFILE/rel/emqx}"
  5. EMQX_WAIT_FOR_START="${EMQX_WAIT_FOR_START:-30}"
  6. export EMQX_WAIT_FOR_START
  7. function check_dashboard_https_ssl_options_depth() {
  8. if [[ $1 =~ v5\.0\.25 ]]; then
  9. EXPECT_DEPTH=5
  10. else
  11. EXPECT_DEPTH=10
  12. fi
  13. DEPTH=$("$EMQX_ROOT"/bin/emqx eval "emqx:get_config([dashboard,listeners,https,ssl_options,depth],10)")
  14. if [[ "$DEPTH" != "$EXPECT_DEPTH" ]]; then
  15. echo "Bad Https depth $DEPTH, expect $EXPECT_DEPTH"
  16. exit 1
  17. fi
  18. }
  19. start_emqx_with_conf() {
  20. echo "Starting $PROFILE with $1"
  21. "$EMQX_ROOT"/bin/emqx start
  22. check_dashboard_https_ssl_options_depth "$1"
  23. "$EMQX_ROOT"/bin/emqx stop
  24. }
  25. MAJOR_VSN=$(./pkg-vsn.sh "$PROFILE" | cut -d. -f1)
  26. if [ "$PROFILE" = "emqx" ]; then
  27. PREFIX="v"
  28. else
  29. PREFIX="e"
  30. fi
  31. FILES=$(ls ./scripts/conf-test/old-confs/"${PREFIX}${MAJOR_VSN}"*)
  32. cp "$EMQX_ROOT"/etc/emqx.conf "$EMQX_ROOT"/etc/emqx.conf.bak
  33. cleanup() {
  34. cp "$EMQX_ROOT"/etc/emqx.conf.bak "$EMQX_ROOT"/etc/emqx.conf
  35. }
  36. trap cleanup EXIT
  37. for file in $FILES; do
  38. cp "$file" "$EMQX_ROOT"/etc/emqx.conf
  39. start_emqx_with_conf "$file"
  40. done