Start PCRF pod.

Change-Id: I42e1b62698faba0d8bf3e01dd1f78fd5018de1d9
diff --git a/omec/omec-control-plane/templates/bin/_pcrf-bootstrap.sh.tpl b/omec/omec-control-plane/templates/bin/_pcrf-bootstrap.sh.tpl
new file mode 100644
index 0000000..4afc210
--- /dev/null
+++ b/omec/omec-control-plane/templates/bin/_pcrf-bootstrap.sh.tpl
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+# Copyright 2020-present Open Networking Foundation
+#
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+set -ex
+
+until cqlsh --file /opt/c3po/pcrfdb/pcrf_cassandra.cql {{ .Values.config.pcrf.pcrfdb }};
+    do echo "Provisioning PCRFDB";
+    sleep 2;
+done
+
diff --git a/omec/omec-control-plane/templates/bin/_pcrf-run.sh.tpl b/omec/omec-control-plane/templates/bin/_pcrf-run.sh.tpl
new file mode 100644
index 0000000..72050cd
--- /dev/null
+++ b/omec/omec-control-plane/templates/bin/_pcrf-run.sh.tpl
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# Copyright 2020-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+set -ex
+
+{{- if .Values.config.coreDump.enabled }}
+cp /bin/pcrf /tmp/coredump/
+{{- end }}
+
+CONF_DIR="/opt/c3po/pcrf/conf"
+LOGS_DIR="/opt/c3po/pcrf/logs"
+#TODO - Need to remove logs directory
+mkdir -p $CONF_DIR $LOGS_DIR
+
+cp /etc/pcrf/conf/{acl.conf,pcrf.json,pcrf.conf,oss.json} $CONF_DIR
+cat $CONF_DIR/{pcrf.json,pcrf.conf}
+
+cd $CONF_DIR
+make_certs.sh {{ tuple "pcrf" "host" . | include "omec-control-plane.diameter_endpoint" }} {{ tuple "pcrf" "realm" . | include "omec-control-plane.diameter_endpoint" }}
+
+cd ..
+pcrf -j $CONF_DIR/pcrf.json
diff --git a/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl b/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl
index 0a5b680..1528dc2 100644
--- a/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl
+++ b/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl
@@ -4,21 +4,48 @@
 #
 # SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
 
+APPLICATION=$1
 set -xe
 
-{{- if .Values.config.coreDump.enabled }}
-cp /bin/ngic_controlplane /tmp/coredump/
-{{- end }}
-
 mkdir -p /opt/cp/config
 cd /opt/cp/config
-cp /etc/cp/config/{*.cfg,*.json} .
+cp /etc/cp/config/{*.cfg,*.json,*.conf,*.sh} .
 
-if [ ! -d "/dev/hugepages" ]; then
-    MEMORY="--no-huge -m $((MEM_LIMIT-1024))"
-fi
-CORES="-c $(taskset -p $$ | awk '{print $NF}')"
-EAL_ARGS="${CORES} ${MEMORY} --no-pci"
+case $APPLICATION in
+    "ngic_controlplane")
+      echo "Starting ngic controlplane app"
+      if [ ! -d "/dev/hugepages" ]; then
+          MEMORY="--no-huge -m $((MEM_LIMIT-1024))"
+      fi
+      CORES="-c $(taskset -p $$ | awk '{print $NF}')"
+      EAL_ARGS="${CORES} ${MEMORY} --no-pci"
+      cat /opt/cp/config/subscriber_mapping.json
+      {{- if .Values.config.coreDump.enabled }}
+      cp /bin/ngic_controlplane /tmp/coredump/
+      {{- end }}
 
-cat /opt/cp/config/subscriber_mapping.json
-ngic_controlplane $EAL_ARGS -- -f /etc/cp/config/
+      ngic_controlplane $EAL_ARGS -- -f /etc/cp/config/
+      ;;
+
+    "gx-app")
+      echo "Starting gx-app"
+      SPGWC_IDENTITY={{ tuple "spgwc" "identity" . | include "omec-control-plane.diameter_endpoint" | quote }};
+      DIAMETER_HOST=$(echo $SPGWC_IDENTITY| cut -d'.' -f1)
+      DIAMETER_REALM={{ tuple "spgwc" "realm" . | include "omec-control-plane.diameter_endpoint" | quote }};
+      chmod +x /bin/make_certs.sh
+      cp /bin/make_certs.sh /opt/cp/config
+      /bin/make_certs.sh $DIAMETER_HOST $DIAMETER_REALM
+      {{- if .Values.config.coreDump.enabled }}
+      cp /bin/gx_app /tmp/coredump/
+      {{- end }}
+      cd /opt/cp/
+      gx_app
+      ;;
+
+    *)
+      echo "invalid app $APPLICATION"
+      ;;
+esac
+    
+
+