Skip to content

Commit

Permalink
fix(util): add conditional sudo for some install_protoc commands (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
nourspace authored and 0o-de-lally committed Nov 30, 2023
1 parent 90e4528 commit 0895124
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions util/dev_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,19 @@ function install_protoc {
return
fi

PRE_COMMAND=()
if [ "$(whoami)" != 'root' ]; then
PRE_COMMAND=(sudo)
fi
TMPFILE=$(mktemp)
rm "$TMPFILE"
mkdir -p "$TMPFILE"/
(
cd "$TMPFILE" || exit
curl -LOs "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_PKG.zip" --retry 3
sudo unzip -o "$PROTOC_PKG.zip" -d /usr/local bin/protoc
sudo unzip -o "$PROTOC_PKG.zip" -d /usr/local 'include/*'
sudo chmod +x "/usr/local/bin/protoc"
"${PRE_COMMAND[@]}" unzip -o "$PROTOC_PKG.zip" -d /usr/local bin/protoc
"${PRE_COMMAND[@]}" unzip -o "$PROTOC_PKG.zip" -d /usr/local 'include/*'
"${PRE_COMMAND[@]}" chmod +x "/usr/local/bin/protoc"
)
rm -rf "$TMPFILE"

Expand Down

0 comments on commit 0895124

Please sign in to comment.