Skip to content

Commit

Permalink
chore(emqx-init): troubleshooting
Browse files Browse the repository at this point in the history
  • Loading branch information
prehor committed Jun 21, 2024
1 parent 3dc61ce commit bfa0495
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions apps/emqx-init/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
#!/bin/bash

echo "EMQX init started..."

set -ex

# Main
case "${1}" in
'')
CURL_PARAMS="-s"
;;
'--debug')
CURL_PARAMS="-v"
;;
*)
echo "ERROR: Unknown option '${1}'" > /dev/stderr
exit 1
esac


: "${INIT_EMQX_HOST:=localhost}"
: "${INIT_EMQX_PORT:=18083}"
: "${INIT_EMQX_SUPER_USER}"
Expand All @@ -17,15 +29,18 @@ INIT_EMQX_BASE_API_URL="http://${INIT_EMQX_SUPER_USER}:${INIT_EMQX_SUPER_PASS}@$
INIT_EMQX_AUTHN_API_URL="${INIT_EMQX_BASE_API_URL}/authentication/password_based:built_in_database/users"
INIT_EMQX_AUTHZ_API_URL="${INIT_EMQX_BASE_API_URL}/authorization/sources/built_in_database/username"

while ! curl -s "${INIT_EMQX_AUTHN_API_URL}"; do
env | sort

while ! curl ${CURL_PARAMS} "${INIT_EMQX_AUTHN_API_URL}"; do
echo 'Waiting for EMQX to start...'
sleep 5
done

echo 'EMQX started, ready to initialize...';

# Authentication
curl -s "${INIT_EMQX_AUTHN_API_URL}" \
curl ${CURL_PARAMS} \
"${INIT_EMQX_AUTHN_API_URL}" \
-H 'Content-Type: application/json' \
-d "$(cat <<EOF
{
Expand All @@ -43,7 +58,8 @@ if [ "${INIT_EMQX_IS_SUPERUSER}" -eq "true" ]; then
fi

# Authorization
curl -s "${INIT_EMQX_AUTHZ_API_URL}" \
curl ${CURL_PARAMS} \
"${INIT_EMQX_AUTHZ_API_URL}" \
-H 'Content-Type: application/json' \
-d "$(cat <<EOF
[
Expand Down

0 comments on commit bfa0495

Please sign in to comment.