run.sh 1.3 KB

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