open-nomad/scripts/vagrant-linux-priv-protoc.sh

38 lines
925 B
Bash
Raw Normal View History

2018-08-01 20:27:06 +00:00
#!/usr/bin/env bash
set -o errexit
# Make sure you grab the latest version
2018-08-01 20:27:06 +00:00
VERSION=3.6.1
DOWNLOAD=https://github.com/google/protobuf/releases/download/v${VERSION}/protoc-${VERSION}-linux-x86_64.zip
function install_protoc() {
if [[ -e /usr/local/bin/protoc ]] ; then
if [ "${VERSION}" = "$(protoc --version | cut -d ' ' -f 2)" ] ; then
return
fi
fi
# Download
curl -sSL --fail -o /tmp/protoc.zip ${DOWNLOAD}
2018-08-01 20:27:06 +00:00
# Unzip
unzip /tmp/protoc.zip -d /tmp/protoc3
2019-01-30 15:57:57 +00:00
# all protoc files should be world-wide readable, specially the include files
chmod -R a+r /tmp/protoc3
2018-08-01 20:27:06 +00:00
# Move protoc to /usr/local/bin/
2019-01-30 15:57:57 +00:00
mv /tmp/protoc3/bin/* /usr/local/bin/
2018-08-01 20:27:06 +00:00
# Move protoc3/include to /usr/local/include/
2019-01-30 15:57:57 +00:00
mv /tmp/protoc3/include/* /usr/local/include/
2018-08-01 20:27:06 +00:00
# Link
2019-01-30 15:57:57 +00:00
ln -s /usr/local/bin/protoc /usr/bin/protoc
rm -rf /tmp/protoc3 /tmp/protoc.zip
2018-08-01 20:27:06 +00:00
}
install_protoc