@@ -61,52 +61,60 @@ echo "Starting with echo server on port: $echo_port and the cmb service on port:
6161# Setup -------------------------------------------------------------------------
6262
6363try () {
64- export ThrewError = false
64+ BASH_COMMAND = " $@ "
65+ ThrewError = false
6566 " $@ " || throw
6667}
6768
6869throw () {
69- echo " An error occurred in : $BASH_COMMAND "
70- export ThrewError = true
70+ echo " An error occurred executing this command : $BASH_COMMAND \n "
71+ ThrewError = true
7172}
7273
7374# Protocol Buffer Compiler ------------------------------------------------------
7475
76+ # Apply any updates
7577echo " Updating modules..."
7678sudo apt-get update
7779
7880# Install Protocol Buffer Compiler (using apt-get)
7981echo " (sudo) Installing protocol bufffer compiler..."
8082try sudo apt-get install -y protobuf-compiler
8183
84+ # If the previous command failed, try without sudo
8285if $ThrewError ; then
83- echo " Installing protocol bufffer compiler..."
86+ echo " (retry no sudo) Installing protocol bufffer compiler..."
8487apt-get install -y protobuf-compiler
88+ else
89+ echo " Installed using sudo!"
8590fi
8691
8792# Add the PROTOC environment variable for Protocol Buffer Compiler
88- try sudo export PROTOC=" /usr/bin/protoc"
93+ export PROTOC=which protoc
94+
95+ # Use the PROTOC env var to see if it is correct by getting the protoc version
96+ try $PROTOC /protoc --version
97+
98+ # If that failed, then the path is incorrect. Try using the next possible path
8999if $ThrewError ; then
90100export PROTOC=" /usr/bin/protoc"
91- fi
92- echo " Set PROTOC = $PROTOC "
93-
101+ # Use the PROTOC env var to see if it is correct by getting the protoc version
94102try $PROTOC /protoc --version
103+ fi
95104
105+ # If that failed, then the path is incorrect. Try using the next possible path
96106if $ThrewError ; then
97- export PROTOC=which protoc
107+ export PROTOC=" /usr/bin"
108+ # Use the PROTOC env var to see if it is correct by getting the protoc version
98109try $PROTOC /protoc --version
110+ fi
111+
99112if $ThrewError ; then
100113echo " Failed to properly run protoc!"
101114exit -1
115+ else
116+ echo " Protocol Buffer Compiler Installed & ENV variables verified!\n PROTOC path is: $PROTOC "
102117fi
103- echo " PROTOC path is: $PROTOC "
104-
105-
106-
107- # Add the Protocol Buffer Compiler install location to the PATH
108- export PATH=" $PROTOC :$PATH "
109- echo " \n Set PATH = $PATH "
110118
111119# Download the protocol buffer release for linux
112120# echo "Downloading protocol bufffer compiler..."
0 commit comments