Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
# https://gist.github.com/sofyanhadia/37787e5ed098c97919b8c593f0ec44d8
# Make sure you grab the latest version
set -euo pipefail
VERSION='3.5.1'
FILENAME=protoc-${VERSION}-linux-x86_64.zip
INSTALL="/opt/protobuf/protoc-${VERSION}"
CURRENT="/opt/protobuf/current"
curl -OL https://github.com/google/protobuf/releases/download/v${VERSION}/${FILENAME}
# Unzip
sudo mkdir -p "$INSTALL"
sudo unzip -o ${FILENAME} -d "$INSTALL"
# create symlink to the current version
if [ -e "$CURRENT" ]; then
sudo unlink "${CURRENT}"
fi
sudo ln -sf "${INSTALL}" "${CURRENT}"
# update access rights
sudo chmod -R a+rx ${INSTALL}/bin
# directories should be READ EXECUTE, but not the files
find /opt/protobuf/ -type d -exec sudo chmod a+rx {} \;
sudo chmod -R a+r ${INSTALL}/include
# link all the includes
sudo ln -sf ${CURRENT}/include/* /usr/local/include/
# XXX MANUALLY
echo "Add ${CURRENT}/bin to your PATH"
# Optional: change owner
# sudo chwon [user] /usr/local/bin/protoc
# sudo chwon -R [user] /usr/local/include/google
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment