Skip to content

Commit

Permalink
feat(install.sh): verify the checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneM committed Jul 31, 2023
1 parent 1f1382c commit cfe8dc1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* feat: add database maintenance info with the new `database-maintenance-info` command ([PR#984](https://github.com/Scalingo/cli/pull/984))
* feat: add database maintenance listing with the new `database-maintenance-list` command ([PR#982](https://github.com/Scalingo/cli/pull/982))
* feat(addons): add maintenance windows manipulation with the new `addon-config` command ([PR#955](https://github.com/Scalingo/cli/pull/955))
* feat(install.sh): verify the archive checksum ([PR#988](https://github.com/Scalingo/cli/pull/988))

### 1.29.1

Expand Down
16 changes: 15 additions & 1 deletion dists/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ main() {

dirname="scalingo_${version}_${os}_${arch}"
archive_name="${dirname}.${ext}"
url=https://github.com/Scalingo/cli/releases/download/${version}/${archive_name}
url="https://github.com/Scalingo/cli/releases/download/${version}/${archive_name}"

status "Downloading Scalingo client... "
curl --silent --fail --location --output ${tmpdir}/${archive_name} ${url}
Expand All @@ -129,6 +129,20 @@ main() {
exit 1
fi
echo "DONE"

status "Verifying the checksum... "
checksums_url="https://github.com/Scalingo/cli/releases/download/${version}/checksums.txt"
checksum_computed=$(sha256sum ${tmpdir}/${archive_name} | cut -d " " -f1)
checksum_expected=$(wget -q --output-document - $checksums_url | grep $archive_name | cut -d " " -f 1)
if [[ "$checksum_computed" != "$checksum_expected" ]]; then
echo "INVALID"
error "Checksums don't match ('$checksum_computed' != '$checksum_expected').\n"
error "You may want to retry to install the Scalingo CLI. If the problem persists, please contact our support team.\n"
exit 1
fi
echo "VALID"
exit -1

status "Extracting... "
tar -C "${tmpdir}" -x -f "${tmpdir}/${archive_name}"

Expand Down

0 comments on commit cfe8dc1

Please sign in to comment.