Skip to content

Commit ae5ebab

Browse files
update
Cleaning up the shell script additions. Adding logMessage and logError in order to make messages easier to distinguish from the rest of the logs. Removed the commented out script since this version seems to do the trick.
1 parent 2a18d32 commit ae5ebab

File tree

1 file changed

+28
-37
lines changed

1 file changed

+28
-37
lines changed

Tools/CI/run_cmb_service.sh

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -60,75 +60,66 @@ echo "Starting with echo server on port: $echo_port and the cmb service on port:
6060

6161
# Setup -------------------------------------------------------------------------
6262

63+
6364
ThrewError=false
65+
66+
# Mimics "Try-Catch" where you have to check if an error occurred after invoking
6467
try() {
6568
ThrewError=false
6669
"$@" || throw "$@"
6770
}
6871

72+
# Invoked by try
6973
throw() {
70-
echo "An error occurred executing this command:$@ \n"
71-
ThrewError=true
74+
logError "An error occurred executing this command:$@"
75+
ThrewError=true
76+
}
77+
78+
# A way to log messages that are easy to distinguish from the rest of the logs
79+
logMessage(){
80+
printf "\n############################################\n"
81+
printf "$@\n"
82+
printf "############################################\n"
83+
}
84+
85+
# A way to log error messages that are easy to distinguish from the rest of the logs
86+
logError(){
87+
printf "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
88+
printf "$@\n"
89+
printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
7290
}
7391

7492
# Protocol Buffer Compiler ------------------------------------------------------
7593

7694
# Apply any updates
77-
echo "Updating modules..."
95+
logMessage "Updating modules..."
7896
sudo apt-get update
7997

8098
# Install Protocol Buffer Compiler (using apt-get)
81-
echo "(sudo) Installing protocol bufffer compiler..."
99+
logMessage "Installing protocol bufffer compiler as SUDO..."
82100
try sudo apt-get install -y protobuf-compiler
83101

84102
# If the previous command failed, try without sudo
85103
if $ThrewError; then
86-
echo "(retry no sudo) Installing protocol bufffer compiler..."
104+
logMessage "Installing protocol bufffer compiler as shell assigned account..."
87105
apt-get install -y protobuf-compiler
88106
else
89-
echo "Installed using sudo!"
107+
logMessage "Protocol bufffer compiler was installed as sudo!"
90108
fi
91109

92-
# Add the PROTOC environment variable for Protocol Buffer Compiler
110+
# Add the PROTOC environment variable that points to the Protocol Buffer Compiler binary
93111
export PROTOC="/usr/bin/protoc"
94112

95-
# Use the PROTOC env var to see if it is correct by getting the protoc version
113+
# Validate the PROTOC env var by getting the protoc version
96114
try $PROTOC --version
97115

98116
if $ThrewError; then
99-
echo "Failed to properly run protoc!"
117+
logError "Failed to properly run protoc!"
100118
exit -1
101119
else
102-
echo "Protocol Buffer Compiler Installed & ENV variables verified!\n PROTOC path is: $PROTOC"
120+
logMessage "Protocol Buffer Compiler Installed & ENV variables verified!\n PROTOC path is: $PROTOC"
103121
fi
104122

105-
# Download the protocol buffer release for linux
106-
# echo "Downloading protocol bufffer compiler..."
107-
# PB_REL="https://github.com/protocolbuffers/protobuf/releases"
108-
# curl -LO $PB_REL/download/v31.1/protoc-31.1-linux-x86_64.zip
109-
110-
# Create target folder to unzip protoc binaries.
111-
# echo "Creating protocol bufffer folder..."
112-
# mkdir -p protoc
113-
# protoc_path="./protoc"
114-
# folder_path=$(realpath "$protoc_path")
115-
116-
# echo "Unzipping to folder path of protoc: $folder_path"
117-
118-
# extract binaries to protoc folder
119-
# unzip protoc-31.1-linux-x86_64.zip -d $folder_path
120-
121-
# changing the execute permissions of the protoc folder
122-
# chmod -R 755 ./protoc
123-
124-
# Add the PROTOC environment variable for Protocol Buffer Compiler
125-
# export PROTOC="$folder_path/bin"
126-
# echo "Set PROTOC = $PROTOC"
127-
128-
# Add the Protocol Buffer Compiler install location to the PATH
129-
# export PATH="$folder_path/bin:$PATH"
130-
# echo "\n Set PATH = $PATH"
131-
132123
# clone the cmb service repo
133124
git clone https://github.com/Unity-Technologies/mps-common-multiplayer-backend.git
134125

0 commit comments

Comments
 (0)