From 9f61cb92b849bf3b49655978c4af88fce40ab542 Mon Sep 17 00:00:00 2001 From: Dane Schneider Date: Fri, 5 Mar 2021 16:16:09 -0800 Subject: [PATCH] install script: fail over to envkey-source-releases.s3.amazonaws.com (public S3 bucket controlled by EnvKey) for envkey-source binary if request to Github Releases fails--workaround for htting low Github rate limits --- README.md | 2 ++ install.sh | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 45c04b5..c521668 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ curl -s https://raw.githubusercontent.com/envkey/envkey-source/master/install.sh ***Note:** the install.sh script writes, then deletes a couple temporary files to the current directory during installation, so make sure you have write permissions for whatever directory you run this command in. In locked down environments, you may want to run it in `$HOME` to be safe.* +***Another Note:** the install.sh script downloads the appropriate envkey-source binary from Github Releases by default, but Github has a fairly low rate limit for unauthenticated requests. For added redundancy, it will fail over to envkey-source-releases.s3.amazonaws.com (an S3 bucket controlled by EnvKey) and download the binary from there if the request to Github Releases fails.* + **Install manually:** Find the [release](https://github.com/envkey/envkey-source/releases) for your platform and architecture, and stick the appropriate binary somewhere in your `PATH` (or wherever you like really). diff --git a/install.sh b/install.sh index 3385d75..de38a25 100755 --- a/install.sh +++ b/install.sh @@ -66,10 +66,18 @@ cleanup () { download_envkey () { echo "Downloading envkey-source binary for ${PLATFORM}-${ARCH}" - url="https://github.com/envkey/envkey-source/releases/download/v${VERSION}/envkey-source_${VERSION}_${PLATFORM}_${ARCH}.tar.gz" - echo "Downloading tarball from ${url}" + url="https://github.com/envkey/envkey-source/releases/download/v${VERSION}/envkey-source_${VERSION}_${PLATFORM}_${ARCH}.tar.gz" + + echo "Downloading tarball from Github Releases: ${url}" curl -s -L -o envkey-source.tar.gz "${url}" + if [ ! -f envkey-source.tar.gz ]; then + echo "Couldn't load tarball from Github Releases: ${url}" + url="https://envkey-source-releases.s3.amazonaws.com/envkey-source_${VERSION}_${PLATFORM}_${ARCH}.tar.gz" + echo "Now attempting to load from s3 bucket backup: ${url}" + curl -s -L -o envkey-source.tar.gz "${url}" + fi + tar zxf envkey-source.tar.gz envkey-source.exe 2> /dev/null tar zxf envkey-source.tar.gz envkey-source 2> /dev/null