Update git submodules
[oom.git] / kubernetes / policy / charts / policy-common / resources / config / scripts / do-start.sh
index 35842e4..ee427af 100644 (file)
@@ -1,4 +1,7 @@
+#!/bin/bash
+
 # Copyright © 2017 Amdocs, Bell Canada, AT&T
+# Modifications Copyright © 2020 AT&T
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -12,7 +15,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-#!/bin/bash
 
 # Script to configure and start the Policy components that are to run in the designated container,
 # It is intended to be used as the entrypoint in the Dockerfile, so the last statement of the
@@ -42,7 +44,7 @@ if [[ -f /opt/app/policy/etc/build.info ]]; then
        echo "Found existing installation, will not reinstall"
        . /opt/app/policy/etc/profile.d/env.sh
 
-else 
+else
        if [[ -d config ]]; then
                cp config/*.conf .
        fi
@@ -59,9 +61,15 @@ else
        . /opt/app/policy/etc/profile.d/env.sh
 
        # install keystore
-       #changed to use http instead of http, so keystore no longer needed
-       #cp config/policy-keystore.jks $POLICY_HOME/etc/ssl/policy-keystore
-       
+        # override the policy keystore and truststore if present
+       if [[ -f config/policy-keystore ]]; then
+               cp config/policy-keystore $POLICY_HOME/etc/ssl
+       fi
+
+       if [[ -f config/policy-truststore ]]; then
+               cp -f config/policy-truststore $POLICY_HOME/etc/ssl
+       fi
+
        if [[ -f config/$container-tweaks.sh ]] ; then
                # file may not be executable; running it as an
                # argument to bash avoids needing execute perms.
@@ -72,21 +80,21 @@ else
                # wait for DB up
                # now that DB is up, invoke database upgrade
                # (which does nothing if the db is already up-to-date)
-               dbuser=$(echo $(grep '^JDBC_USER=' base.conf | cut -f2 -d=))
-               dbpw=$(echo $(grep '^JDBC_PASSWORD=' base.conf | cut -f2 -d=))
-               db_upgrade_remote.sh $dbuser $dbpw {{.Release.Name}}-{{.Values.global.mariadb.nameOverride}}
+               if [[ -v JDBC_USER ]]; then
+                       dbuser=${JDBC_USER};
+               else
+                       dbuser=$(echo $(grep '^JDBC_USER=' base.conf | cut -f2 -d=))
+               fi
+
+               if [[ -v JDBC_PASSWORD ]]; then
+                       dbpw=${JDBC_PASSWORD}
+               else
+                       dbpw=$(echo $(grep '^JDBC_PASSWORD=' base.conf | cut -f2 -d=))
+               fi
+               db_upgrade_remote.sh $dbuser $dbpw {{.Values.global.mariadb.service.name}}
        fi
 
 fi
 
 policy.sh start
-
-# on pap, wait for pap, pdp, brmsgw, nexus and drools up,
-# then push the initial default policies
-if [[ $container == pap ]]; then
-       # wait addional 1 minute for all processes to get fully initialized and synched up
-       sleep 60
-       bash -xv config/push-policies.sh
-fi
-
 sleep 1000d