|
| 1 | +#!/bin/bash |
| 2 | +# ---------------------------------------------------------------- |
| 3 | +# Copyright 2018 Cisco Systems |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# ------------------------------------------------------------------ |
| 17 | +# |
| 18 | +# dependencies_linux_gnmi.sh |
| 19 | +# Script to install protobuf, protoc and grpc on Ubuntu and CentOS |
| 20 | +# for running YDK gNMI tests on docker |
| 21 | +# |
| 22 | +# ------------------------------------------------------------------ |
| 23 | + |
| 24 | +function print_msg { |
| 25 | + echo -e "${MSG_COLOR}*** $(date) *** dependencies_linux_gnmi.sh | $@ ${NOCOLOR}" |
| 26 | +} |
| 27 | + |
| 28 | +function install_protobuf { |
| 29 | + print_msg "Downloading protobuf and protoc" |
| 30 | + wget https://github.com/google/protobuf/releases/download/v3.5.0/protobuf-cpp-3.5.0.zip > /dev/null |
| 31 | + unzip protobuf-cpp-3.5.0.zip > /dev/null |
| 32 | + cd protobuf-3.5.0 |
| 33 | + print_msg "Configuring protobuf and protoc" |
| 34 | + ./configure > /dev/null |
| 35 | + print_msg "Compiling protobuf and protoc" |
| 36 | + make > /dev/null |
| 37 | + print_msg "Installing protobuf and protoc" |
| 38 | + sudo make install |
| 39 | + sudo ldconfig |
| 40 | + cd - |
| 41 | +} |
| 42 | + |
| 43 | +function install_grpc { |
| 44 | + print_msg "Installing grpc" |
| 45 | + |
| 46 | + git clone -b v1.9.1 https://github.com/grpc/grpc |
| 47 | + cd grpc |
| 48 | + git submodule update --init |
| 49 | + sudo ldconfig |
| 50 | + make > /dev/null |
| 51 | + sudo make install |
| 52 | + sudo ldconfig |
| 53 | + cd - |
| 54 | +} |
| 55 | + |
| 56 | +########################## EXECUTION STARTS HERE ############################# |
| 57 | + |
| 58 | +# Terminal colors |
| 59 | +NOCOLOR="\033[0m" |
| 60 | +YELLOW='\033[1;33m' |
| 61 | +MSG_COLOR=$YELLOW |
| 62 | + |
| 63 | +install_protobuf |
| 64 | +install_grpc |
0 commit comments