Lusheng Ji | 37534a5 | 2020-08-02 21:25:26 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | ################################################################################ |
| 3 | # Copyright (c) 2020 AT&T Intellectual Property. # |
| 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 | #set -x |
| 19 | |
| 20 | acknowledge() { |
| 21 | if [ ! -z "$1" ]; then echo "$1"; fi |
| 22 | read -n 1 -p "Press any key to continue, or CTRL-C to abort" mainmenuinput |
| 23 | echo |
| 24 | } |
| 25 | |
| 26 | |
| 27 | echo "This script sets up the IP address references for RIC and SMO clusters." |
| 28 | echo |
| 29 | echo "Reading RIC cluster IP address from envirronment variable \$RIC_IP." |
| 30 | if [ -z $(echo ${RIC_IP} | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}") ]; then |
| 31 | read -p "Not found or not in right format. Enter the external IP address of the RIC cluster: " RIC_IP |
| 32 | echo |
| 33 | else |
| 34 | echo " Got ${RIC_IP}" |
| 35 | fi |
| 36 | |
| 37 | echo "Reading SMO cluster IP address from envirronment variable \$SMO_IP." |
| 38 | if [ -z $(echo ${SMO_IP} | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}") ]; then |
| 39 | read -p "Not found or not in right format. Enter the external IP address of the SMO cluster: " SMO_IP |
| 40 | echo |
| 41 | else |
| 42 | echo " Got ${SMO_IP}" |
| 43 | fi |
| 44 | |
| 45 | echo |
| 46 | echo "Ready to configure demo scripts and Helm charts using RIC cluster at ${RIC_IP} and SMO cluster at ${SMO_IP}." |
| 47 | echo "If not correct, abort from this script, then export the correct values for the RIC_IP and SMO_IP environment variables." |
| 48 | acknowledge |
| 49 | |
| 50 | export RIC_IP="$RIC_IP" |
| 51 | export SMO_IP="$SMO_IP" |
| 52 | |
| 53 | # run fixes from git clone's root directory |
| 54 | PREVDIR="$PWD" |
| 55 | cd $(git rev-parse --show-toplevel) |
| 56 | |
| 57 | if [ ! "$(ls -A ./ric-dep)" ]; then |
| 58 | echo "ric-dep directory empty, running submodule command to fetch" |
| 59 | git submodule update --init --recursive |
| 60 | echo |
| 61 | fi |
| 62 | |
| 63 | echo "Inject the RIC cluster IP address (${RIC_IP}) into NONRTRIC recipe..." |
| 64 | #./nonrtric/RECIPE_EXAMPLE/example_recipe.yaml:137:192.168.130.80 |
| 65 | sed -i -e 's/"baseUrl":"http:\/\/192.168.130.80:32080\/a1mediator"/"baseUrl":"http:\/\/'"${RIC_IP}"':32080\/a1mediator"/g' ./nonrtric/RECIPE_EXAMPLE/example_recipe.yaml |
| 66 | |
| 67 | |
| 68 | echo "Inject the RIC and SMO cluster IP addresses (${RIC_IP} and ${SMO_IP}) into RICAUX recipe..." |
| 69 | #./ric-aux/RECIPE_EXAMPLE/example_recipe.yaml:40:ricip: "10.0.0.1" |
| 70 | #./ric-aux/RECIPE_EXAMPLE/example_recipe.yaml:40:auxip: "10.0.0.1" |
| 71 | sed -i -e 's/ricip: "10.0.0.1"/ricip: "'"${RIC_IP}"'"/g' ./ric-aux/RECIPE_EXAMPLE/example_recipe.yaml |
| 72 | sed -i -e 's/auxip: "10.0.0.1"/auxip: "'"${SMO_IP}"'"/g' ./ric-aux/RECIPE_EXAMPLE/example_recipe.yaml |
| 73 | |
| 74 | echo "Inject the RIC and SMO cluster IP addresses (${RIC_IP} and ${SMO_IP}) into RIC recipe..." |
| 75 | #ric-dep/RECIPE_EXAMPLE/example_recipe.yaml:39: ricip: "10.0.0.1" |
| 76 | #ric-dep/RECIPE_EXAMPLE/example_recipe.yaml:40: auxip: "10.0.0.1" |
| 77 | sed -i -e 's/ricip: "10.0.0.1"/ricip: "'"${RIC_IP}"'"/g' ./ric-dep/RECIPE_EXAMPLE/example_recipe.yaml |
| 78 | sed -i -e 's/auxip: "10.0.0.1"/auxip: "'"${SMO_IP}"'"/g' ./ric-dep/RECIPE_EXAMPLE/example_recipe.yaml |
| 79 | |
| 80 | |
| 81 | echo |
| 82 | echo "Completed." |
| 83 | cd "$PREVDIR" |