瀏覽代碼

chore(scripts): get-dashboard.sh accepts URL as arg

Also move it to scripts dir
Zaiming Shi 5 年之前
父節點
當前提交
534b6c0062
共有 2 個文件被更改,包括 12 次插入9 次删除
  1. 1 1
      Makefile
  2. 11 8
      get-dashboard.sh

+ 1 - 1
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)

+ 11 - 8
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")"
-
-DOWNLOAD_URL='https://github.com/emqx/emqx-dashboard-frontend/releases/download'
+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
 
-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"