linkerd2/bin/protoc

32 lines
676 B
Bash
Executable File

#!/usr/bin/env sh
set -eu
if [ "$(uname -s)" = Darwin ]; then
os=osx
else
os=linux
fi
arch=$(uname -m)
bindir=$( cd "${0%/*}" && pwd )
targetbin=$( cd "$bindir"/.. && pwd )/target/bin
protocversion=3.6.0
protocbin=$targetbin/protoc-$protocversion
protocurl=https://github.com/google/protobuf/releases/download/v$protocversion/protoc-$protocversion-$os-$arch.zip
if [ ! -f "$protocbin" ]; then
tmp=$(mktemp -d -t protoc.XXX)
mkdir -p "$targetbin"
(
cd "$tmp"
curl -L --silent --fail -o "./protoc.zip" "$protocurl"
unzip -q "./protoc.zip" bin/protoc
chmod +x bin/protoc
)
mv "$tmp/bin/protoc" "$protocbin"
rm -rf "$tmp"
fi
"$protocbin" "$@"