pomerium/scripts/get-envoy.bash
Caleb Doxsey 1eea197859
darwin: use x86 envoy build for arm64 (#2246)
* darwin: use x86 envoy build for arm64

* allow arm64 build for darwin
2021-05-28 15:59:09 -07:00

47 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
set -euo pipefail
PATH="$PATH:$(go env GOPATH)/bin"
export PATH
_envoy_version=1.17.3
_dir="${DIR:-"$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/../bin"}"
_target="${TARGET:-"$(go env GOOS)-$(go env GOARCH)"}"
# until m1 macs are supported, fallback to x86 and use rosetta
if [ "$_target" == "darwin-arm64" ]; then
_target="darwin-amd64"
fi
is_command() {
command -v "$1" >/dev/null
}
hash_sha256() {
TARGET=${1:-/dev/stdin}
if is_command gsha256sum; then
hash=$(gsha256sum "$TARGET") || return 1
echo "$hash" | cut -d ' ' -f 1
elif is_command sha256sum; then
hash=$(sha256sum "$TARGET") || return 1
echo "$hash" | cut -d ' ' -f 1
elif is_command shasum; then
hash=$(shasum -a 256 "$TARGET" 2>/dev/null) || return 1
echo "$hash" | cut -d ' ' -f 1
elif is_command openssl; then
hash=$(openssl -dst openssl dgst -sha256 "$TARGET") || return 1
echo "$hash" | cut -d ' ' -f a
else
echo "hash_sha256 unable to find command to compute sha-256 hash"
return 1
fi
}
if [ -f "$_dir/envoy" ]; then
exit 0
fi
mkdir -p "$_dir"
curl -L --compressed -o "$_dir/envoy" "https://github.com/pomerium/envoy-binaries/releases/download/v${_envoy_version}/envoy-${_target}"
hash_sha256 "$_dir/envoy" >"$_dir/envoy.sha256"