-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do checksum check after downloading platform zip file (#125)
Signed-off-by: Lenin Mehedy <[email protected]>
- Loading branch information
1 parent
8fd976b
commit 3d91617
Showing
6 changed files
with
78 additions
and
69 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
# This script fetch the build.zip file and checksum file from builds.hedera.com and then extract it into HapiApp2 directory | ||
# Usage extract-platform <release-version> | ||
# e.g. extract-platform v0.42.5 | ||
|
||
readonly tag="${1}" | ||
if [ -z "${tag}" ]; then | ||
echo "Release tag is required (e.g. v0.42.5)"; | ||
exit 1 | ||
fi | ||
|
||
readonly HAPI_DIR=/opt/hgcapp/services-hedera/HapiApp2.0 | ||
readonly HEDERA_USER_HOME_DIR=/home/hedera | ||
readonly HEDERA_BUILDS_URL='https://builds.hedera.com' | ||
readonly RELEASE_DIR="$(awk -F'.' '{print $1"."$2}' <<< "${tag}")" | ||
readonly BUILD_ZIP_FILE="${HEDERA_USER_HOME_DIR}/build-${tag}.zip" | ||
readonly BUILD_ZIP_URL="${HEDERA_BUILDS_URL}/node/software/${RELEASE_DIR}/build-${tag}.zip" | ||
readonly CHECKSUM_FILE="${HEDERA_USER_HOME_DIR}/build-${tag}.sha384" | ||
readonly CHECKSUM_URL="${HEDERA_BUILDS_URL}/node/software/${RELEASE_DIR}/build-${tag}.sha384" | ||
|
||
# download | ||
echo "Downloading ${BUILD_ZIP_URL}" | ||
[ -f "${BUILD_ZIP_FILE}" ] || curl -sSf "${BUILD_ZIP_URL}" -o "${BUILD_ZIP_FILE}" | ||
[ $? == 0 ] || exit 1 | ||
echo "Downloading ${CHECKSUM_URL}" | ||
[ -f "${CHECKSUM_FILE}" ] || curl -sSf "${CHECKSUM_URL}" -o "${CHECKSUM_FILE}" | ||
[ $? == 0 ] || exit 1 | ||
readonly sum="$(openssl dgst -sha384 "${BUILD_ZIP_FILE}" | awk '{print $2}')" | ||
readonly expected_sum="$(awk '{print $1}' < "${CHECKSUM_FILE}")" | ||
if [ "${sum}" != "${expected_sum}" ]; then | ||
echo "SHA sum of ${BUILD_ZIP_FILE} does not match. Aborting." | ||
exit 1 | ||
fi | ||
|
||
# extract | ||
echo "Extracting ${BUILD_ZIP_FILE}" | ||
[[ -d "${HAPI_DIR}" ]] || mkdir -p "${HAPI_DIR}" | ||
cd "${HAPI_DIR}" && jar xvf "${BUILD_ZIP_FILE}" | ||
[ $? == 0 ] || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters