diff --git a/Makefile b/Makefile index c3dbc28a2..5dc0d60f7 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ $(REBAR): ensure-rebar3 .PHONY: get-dashboard get-dashboard: - $(CURDIR)/get-dashboard.sh $(DASHBOARD_VERSION) + $(CURDIR)/scripts/get-dashboard.sh $(DASHBOARD_VERSION) .PHONY: eunit eunit: $(REBAR) diff --git a/get-dashboard.sh b/scripts/get-dashboard.sh similarity index 56% rename from get-dashboard.sh rename to scripts/get-dashboard.sh index 991f2b39d..48a846112 100755 --- a/get-dashboard.sh +++ b/scripts/get-dashboard.sh @@ -1,15 +1,18 @@ #!/bin/bash -set -eu +## NOTE: execute this script in the project root -VERSION="$1" +set -euo pipefail -# ensure dir -cd -P -- "$(dirname -- "$0")" +if [[ "$1" == https://* ]]; then + VERSION='*' # alwyas download + DOWNLOAD_URL="$1" +else + VERSION="$1" + DOWNLOAD_URL="https://github.com/emqx/emqx-dashboard-frontend/releases/download/${VERSION}/emqx-dashboard.zip" +fi -DOWNLOAD_URL='https://github.com/emqx/emqx-dashboard-frontend/releases/download' - -if [ "$EMQX_ENTERPRISE" = 'true' ] || [ "$EMQX_ENTERPRISE" == '1' ]; then +if [ "${EMQX_ENTERPRISE:-}" = 'true' ] || [ "${EMQX_ENTERPRISE:-}" == '1' ]; then DASHBOARD_PATH='lib-ee/emqx_dashboard/priv' else DASHBOARD_PATH='lib-ce/emqx_dashboard/priv' @@ -28,7 +31,7 @@ if [ -d "$DASHBOARD_PATH/www" ] && [ "$(version)" = "$VERSION" ]; then exit 0 fi -curl -f -L "${DOWNLOAD_URL}/${VERSION}/emqx-dashboard.zip" -o ./emqx-dashboard.zip +curl -f -L "${DOWNLOAD_URL}" -o ./emqx-dashboard.zip unzip -q ./emqx-dashboard.zip -d "$DASHBOARD_PATH" rm -rf "$DASHBOARD_PATH/www" mv "$DASHBOARD_PATH/dist" "$DASHBOARD_PATH/www"