Skip to content

Commit 14713cf

Browse files
fix
Fixing some issues with my bad bash scripting. Adjusting script to better reflect the status as well to verify the PROTOC path is correct.
1 parent 1636c28 commit 14713cf

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

Tools/CI/run_cmb_service.sh

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,52 +61,60 @@ echo "Starting with echo server on port: $echo_port and the cmb service on port:
6161
# Setup -------------------------------------------------------------------------
6262

6363
try() {
64-
export ThrewError = false
64+
BASH_COMMAND = "$@"
65+
ThrewError = false
6566
"$@" || throw
6667
}
6768

6869
throw() {
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
7577
echo "Updating modules..."
7678
sudo apt-get update
7779

7880
# Install Protocol Buffer Compiler (using apt-get)
7981
echo "(sudo) Installing protocol bufffer compiler..."
8082
try sudo apt-get install -y protobuf-compiler
8183

84+
# If the previous command failed, try without sudo
8285
if $ThrewError; then
83-
echo "Installing protocol bufffer compiler..."
86+
echo "(retry no sudo) Installing protocol bufffer compiler..."
8487
apt-get install -y protobuf-compiler
88+
else
89+
echo "Installed using sudo!"
8590
fi
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
8999
if $ThrewError; then
90100
export 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
94102
try $PROTOC/protoc --version
103+
fi
95104

105+
# If that failed, then the path is incorrect. Try using the next possible path
96106
if $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
98109
try $PROTOC/protoc --version
110+
fi
111+
99112
if $ThrewError; then
100113
echo "Failed to properly run protoc!"
101114
exit -1
115+
else
116+
echo "Protocol Buffer Compiler Installed & ENV variables verified!\n PROTOC path is: $PROTOC"
102117
fi
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

Comments
 (0)