diff --git a/scripts/relup-base-packages.sh b/scripts/relup-base-packages.sh index 2999b8e0d..17f0d6ab4 100755 --- a/scripts/relup-base-packages.sh +++ b/scripts/relup-base-packages.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash + +## This script helps to download relup base version packages + if [[ -n "$DEBUG" ]]; then set -x fi @@ -6,24 +9,27 @@ set -euo pipefail PROFILE="${1}" if [ "$PROFILE" = "" ]; then - $PROFILE="emqx" + PROFILE="emqx" fi case $PROFILE in "emqx") - DIR="broker" + DIR='broker' + EDITION='community' ;; "emqx-ee") - DIR="enterprise" + DIR='enterprise' + EDITION='enterprise' ;; "emqx-edge") - DIR="edge" + DIR='edge' + EDITION='edge' ;; esac -SYSTEM="$(./scripts/get-distro.sh)" +SYSTEM="${SYSTEM:-$(./scripts/get-distro.sh)}" -ARCH="$(uname -m)" +ARCH="${ARCH:-$(uname -m)}" case "$ARCH" in x86_64) ARCH='amd64' @@ -47,16 +53,18 @@ cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/.." mkdir -p _upgrade_base pushd _upgrade_base -for tag in $(../scripts/relup-base-vsns.sh community | xargs echo -n); do - if [ ! -f "$PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.zip" ] \ - && [ ! -z "$(echo $(curl -I -m 10 -o /dev/null -s -w %{http_code} https://www.emqx.com/downloads/$DIR/$tag/$PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.zip) | grep -oE "^[23]+")" ];then - wget --no-verbose https://www.emqx.com/downloads/$DIR/$tag/$PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.zip +for tag in $(../scripts/relup-base-vsns.sh $EDITION | xargs echo -n); do + filename="$PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.zip" + url="https://www.emqx.com/downloads/$DIR/$tag/$filename" + echo "downloading ${filename} ..." + if [ ! -f "$filename" ] && curl -I -m 10 -o /dev/null -s -w "%{http_code}" "${url}" | grep -q -oE "^[23]+" ; then + curl -L -o "${filename}" "${url}" if [ "$SYSTEM" != "centos6" ]; then - wget --no-verbose https://www.emqx.com/downloads/$DIR/$tag/$PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.zip.sha256 + curl -L -o "${filename}.sha256" "${url}.sha256" ## https://askubuntu.com/questions/1202208/checking-sha256-checksum - echo "$(cat $PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.zip.sha256) $PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.zip" | $SHASUM -c || exit 1 + echo "$(cat "${filename}.sha256") ${filename}" | $SHASUM -c || exit 1 fi fi -done +done popd diff --git a/scripts/shellcheck.sh b/scripts/shellcheck.sh index 5f8cdfd51..97445829f 100755 --- a/scripts/shellcheck.sh +++ b/scripts/shellcheck.sh @@ -3,7 +3,11 @@ set -euo pipefail target_files=() -while IFS='' read -r line; do target_files+=("$line"); done < <(grep -r -l --exclude-dir=.git --exclude-dir=_build "#!/bin/" .) +while IFS='' read -r line; +do + target_files+=("$line"); +done < <(git grep -r -l '^#!/\(bin/\|usr/bin/env bash\)' .) + return_code=0 for i in "${target_files[@]}"; do echo checking "$i" ...