blob: a15e83cf5cd67048f65eb1c96b64137f07b9804d [file] [log] [blame]
Hyunsun Moon06f98552019-08-15 13:44:47 -06001#!/bin/sh
Hyunsun Moon636e17d2019-07-03 12:52:15 -05002#
3# Copyright 2019-present Open Networking Foundation
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
17set -ex
18
19cp /opt/mme/config/config.json /opt/mme/config/shared/config.json
20cd /opt/mme/config/shared
21
22# Set local IP address for s1ap and s11 networks to the config
23jq --arg MME_LOCAL_IP "$MME_LOCAL_IP" '.mme.ip_addr=$MME_LOCAL_IP' config.json > config.tmp && mv config.tmp config.json
24jq --arg MME_LOCAL_IP "$MME_LOCAL_IP" '.s1ap.s1ap_local_addr=$MME_LOCAL_IP' config.json > config.tmp && mv config.tmp config.json
25jq --arg MME_LOCAL_IP "$MME_LOCAL_IP" '.s11.egtp_local_addr=$MME_LOCAL_IP' config.json > config.tmp && mv config.tmp config.json
26
27# Set SPGW-C address to the config
28SPGWC_POD={{ tuple "spgwc" "identity" . | include "mcord-services.endpoint_lookup" | quote }}
29SPGWC_ADDR=$(dig +short $SPGWC_POD)
30jq --arg SPGWC_ADDR "$SPGWC_ADDR" '.s11.sgw_addr //= $SPGWC_ADDR' config.json > config.tmp && mv config.tmp config.json
31jq --arg SPGWC_ADDR "$SPGWC_ADDR" '.s11.pgw_addr //= $SPGWC_ADDR' config.json > config.tmp && mv config.tmp config.json
32
33# Add additional redundant keys - should be fixed in openmme
34HSS_TYPE=$(jq -r '.s6a.host_type' config.json)
35HSS_HOST=$(jq -r '.s6a.host' config.json)
36jq --arg HSS_TYPE "$HSS_TYPE" '.s6a.hss_type=$HSS_TYPE' config.json > config.tmp && mv config.tmp config.json
37jq --arg HSS_HOST "$HSS_HOST" '.s6a.host_name=$HSS_HOST' config.json > config.tmp && mv config.tmp config.json
38
39# Copy the final configs for each applications
40cp /opt/mme/config/shared/config.json /opt/mme/config/shared/mme.json
41cp /opt/mme/config/shared/config.json /opt/mme/config/shared/s11.json
42cp /opt/mme/config/shared/config.json /opt/mme/config/shared/s1ap.json
43cp /opt/mme/config/shared/config.json /opt/mme/config/shared/s6a.json
44cp /opt/mme/config/s6a_fd.conf /opt/mme/config/shared/s6a_fd.conf
45
46# Generate certs
47MME_IDENTITY={{ tuple "mme" "identity" . | include "mcord-services.endpoint_lookup" | quote }};
48DIAMETER_HOST=$(echo $MME_IDENTITY | cut -d'.' -f1)
49DIAMETER_REALM={{ tuple "mme" "realm" . | include "mcord-services.endpoint_lookup" | quote }};
50
51cp /openmme/target/conf/make_certs.sh /opt/mme/config/shared/make_certs.sh
52cd /opt/mme/config/shared
53./make_certs.sh $DIAMETER_HOST $DIAMETER_REALM