Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(install.sh): better error message if fails to get the version #748

Merged
merged 4 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### To be Released

* fix(install.sh): better error message if fails to get the version [#748](https://github.com/Scalingo/cli/pull/748)
* feat(logs): possibility to get the addon logs by using its type (e.g. Redis) [#745](https://github.com/Scalingo/cli/pull/745)
* fix(error): interpret raw newline [#744](https://github.com/Scalingo/cli/pull/744)
* fix(stats): display memory as IEC size [#742](https://github.com/Scalingo/cli/pull/742)
Expand Down
24 changes: 21 additions & 3 deletions dists/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,25 @@ main() {

tmpdir=$(mktemp -d /tmp/scalingo_cli_XXX)
trap "clean_install ${tmpdir}" EXIT
version=$(curl -s https://cli-dl.scalingo.com/version | tr -d ' \t\n')

version=$(curl --silent https://cli-dl.scalingo.com/version | tr -d ' \t\n')
if [ -z "$version" ]; then
echo "-----> Fail to get the version of the CLI" >&2
echo "You probably have an old version of curl. Please check your curl version and update accordingly." >&2
exit 1
fi

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

status "Downloading Scalingo client... "
curl -s -L -o ${tmpdir}/${archive_name} ${url}
curl --silent --fail --location --output ${tmpdir}/${archive_name} ${url}
if [ ! -f ${tmpdir}/${archive_name} ]; then
echo "" >&2
echo "-----> Fail to download the CLI archive" >&2
exit 1
fi
echo "DONE"
status "Extracting... "
case $ext in
Expand All @@ -118,9 +130,15 @@ main() {
tar -C "${tmpdir}" -x -f "${tmpdir}/${archive_name}"
;;
esac
echo "DONE"

exe_path=${tmpdir}/${dirname}/scalingo
if [ ! -f "$exe_path" ]; then
echo "" >&2
echo "-----> Fail to extract the CLI archive" >&2
exit 1
fi
echo "DONE"

target_dir="${target_dir:-/usr/local/bin}"
target="$target_dir/scalingo"

Expand Down