relup-base-packages.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/env bash
  2. ## This script helps to download relup base version packages
  3. if [[ -n "$DEBUG" ]]; then set -x; fi
  4. set -euo pipefail
  5. # ensure dir
  6. cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
  7. ROOT_DIR="$(pwd)"
  8. PROFILE="${1:-emqx}"
  9. export PROFILE
  10. case $PROFILE in
  11. "emqx")
  12. DIR='broker'
  13. EDITION='community'
  14. ;;
  15. "emqx-enterprise")
  16. DIR='enterprise'
  17. EDITION='enterprise'
  18. ;;
  19. *)
  20. echo "Unknown profile $PROFILE"
  21. exit 1
  22. ;;
  23. esac
  24. UNAME="$(uname -s)"
  25. case "$UNAME" in
  26. Darwin)
  27. SHASUM="shasum -a 256"
  28. ;;
  29. *)
  30. SHASUM="sha256sum"
  31. ;;
  32. esac
  33. BASE_VERSIONS="$("${ROOT_DIR}"/scripts/relup-base-vsns.sh "$EDITION" | xargs echo -n)"
  34. fullvsn() {
  35. env PKG_VSN="$1" "${ROOT_DIR}"/pkg-vsn.sh "$PROFILE" --long
  36. }
  37. mkdir -p _upgrade_base
  38. pushd _upgrade_base >/dev/null
  39. for tag in ${BASE_VERSIONS}; do
  40. filename="$PROFILE-$(fullvsn "${tag#[e|v]}").tar.gz"
  41. url="https://www.emqx.com/downloads/$DIR/$tag/$filename"
  42. echo "downloading ${filename} ..."
  43. ## if the file does not exist (not downloaded yet)
  44. ## and there is such a package to downlaod
  45. if [ ! -f "$filename" ] && curl -I -m 10 -o /dev/null -s -w "%{http_code}" "${url}" | grep -q -oE "^[23]+" ; then
  46. curl -L -o "${filename}" "${url}"
  47. curl -L -o "${filename}.sha256" "${url}.sha256"
  48. ## https://askubuntu.com/questions/1202208/checking-sha256-checksum
  49. echo "$(cat "${filename}.sha256") ${filename}" | $SHASUM -c || exit 1
  50. fi
  51. done
  52. popd >/dev/null