Skip to content

Instantly share code, notes, and snippets.

@chriscz
Forked from sofyan-ahmad/Install protobuf 3 on Ubuntu
Last active February 19, 2018 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriscz/0f00ec90b2ef9d0a4413ab75a8e435a0 to your computer and use it in GitHub Desktop.
Save chriscz/0f00ec90b2ef9d0a4413ab75a8e435a0 to your computer and use it in GitHub Desktop.
#!/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