X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=sim%2Fe2-interface.git;a=blobdiff_plain;f=e2sim%2Fe2apv1sim%2Fhelm%2Fe2sim%2Ftemplates%2Fbin%2F_e2sim-run.sh.tpl;fp=e2sim%2Fe2apv1sim%2Fhelm%2Fe2sim%2Ftemplates%2Fbin%2F_e2sim-run.sh.tpl;h=35e01c4f99df56ec88d2b6819ea78075baf93f40;hp=0000000000000000000000000000000000000000;hb=0eba05c4ff0c99974d3f3a63b65cbe2adb209e51;hpb=c380e183231711cf9f8bc72d0eb52e532dd07085 diff --git a/e2sim/e2apv1sim/helm/e2sim/templates/bin/_e2sim-run.sh.tpl b/e2sim/e2apv1sim/helm/e2sim/templates/bin/_e2sim-run.sh.tpl new file mode 100755 index 0000000..35e01c4 --- /dev/null +++ b/e2sim/e2apv1sim/helm/e2sim/templates/bin/_e2sim-run.sh.tpl @@ -0,0 +1,54 @@ +{{/* + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/}} +#!/bin/sh + +# Launch the e2 simulator on ${E2SIM_BIND_ADDR}:${E2SIM_BIND_PORT} +# If E2SIM_BIND_ADDR is not supplied, picks the address of the interface +# associated with the default route for E2SIM_BIND_AF (either +# "inet" [default] or "inet6"). + +if [ -z "${E2SIM_BIND_ADDR}" ]; then + if [ `echo "x${E2SIM_BIND_AF}x" | tr [A-Z] [a-z]` != "xinet6x" ]; then + AF='inet' + DEFROUTE='0/0' + LO='127.0.0.1' + else + AF='inet6' + DEFROUTE='::0/0' + LO='00:00:00:00:00:00' + fi + if [ -z "${E2SIM_BIND_IF}" ]; then + # bind on the address associated with the default route + E2SIM_BIND_IF=`ip -br -f ${AF} route show ${DEFROUTE}| sed 's/.*dev[\ ]*\([^\ ]*\).*/\1/'` + if [ -z ${E2SIM_BIND_IF} ]; then + # this is kinda bogus, but it's the only real fallback: take the first + # non-loopback interface. + E2SIM_BIND_IF=`ip -f ${AF} -o link list up | grep -v LOOPBACK | head -1 |awk -F: '{print $2}'` + fi + fi + E2SIM_BIND_ADDR=`ip -f ${AF} -o addr show ${E2SIM_BIND_IF:-eth0} scope global | sed -e 's/.*inet[6\ ]*\([^\ ]*\)\/.*/\1/'` +fi + +if [ -z $E2SIM_BIND_ADDR ]; then + # search failed. be nondestructively useless. + echo "No suitable address found, binding on loopback addess ${LO}" + E2SIM_BIND_ADDR=${LO} +else + echo "e2sim starting at ${E2SIM_BIND_ADDR}:${E2SIM_PORT:-36421}" +fi + +${E2SIM:-/home/e2sim/build/e2sim} ${E2SIM_BIND_ADDR} ${E2SIM_PORT:-36421}