3 #============LICENSE_START==================================================
5 #===========================================================================
6 # Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
7 #===========================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #============LICENSE_END==================================================
23 # Script to configure and start the Policy components that are to run in the designated container,
24 # It is intended to be used as the entrypoint in the Dockerfile, so the last statement of the
25 # script just goes into a long sleep so that the script does not exit (which would cause the
26 # container to be torn down).
32 comps="base pap paplp console mysql elk"
35 comps="base pdp pdplp"
41 echo "Usage: do-start.sh pap|pdp|brmsgw" >&2
46 # skip installation if build.info file is present (restarting an existing container)
47 if [[ -f /opt/app/policy/etc/build.info ]]; then
48 echo "Found existing installation, will not reinstall"
49 . /opt/app/policy/etc/profile.d/env.sh
52 if [[ -d config ]]; then
56 for comp in $comps; do
57 echo "Installing component: $comp"
58 ./docker-install.sh --install $comp
60 for comp in $comps; do
61 echo "Configuring component: $comp"
62 ./docker-install.sh --configure $comp
65 . /opt/app/policy/etc/profile.d/env.sh
67 # override the policy keystore and truststore if present
69 if [[ -f config/policy-keystore ]]; then
70 cp config/policy-keystore $POLICY_HOME/etc/ssl
73 if [[ -f config/policy-truststore ]]; then
74 cp -f config/policy-trustore ${POLICY_HOME}/etc/ssl
77 if [[ -f config/$container-tweaks.sh ]] ; then
78 # file may not be executable; running it as an
79 # argument to bash avoids needing execute perms.
80 bash config/$container-tweaks.sh
83 if [[ $container == pap ]]; then
85 ./wait-for-port.sh mariadb 3306
86 # now that DB is up, invoke database upgrade
87 # (which does nothing if the db is already up-to-date)
88 dbuser=$(echo $(grep '^JDBC_USER=' base.conf | cut -f2 -d=))
89 dbpw=$(echo $(grep '^JDBC_PASSWORD=' base.conf | cut -f2 -d=))
90 db_upgrade_remote.sh $dbuser $dbpw mariadb
95 # pap needs to wait for mariadb up before starting;
96 # others need to wait for pap up (in case it had to do db upgrade)
97 if [[ $container == pap ]]; then
98 # we may have already done this above, but doesn't hurt to repeat
99 ./wait-for-port.sh mariadb 3306
101 ./wait-for-port.sh pap 9091
106 # on pap, wait for pap, pdp, brmsgw, nexus and drools up,
107 # then push the initial default policies
108 if [[ $container == pap ]]; then
109 ./wait-for-port.sh pap 9091
110 ./wait-for-port.sh pdp 8081
111 # brmsgw doesn't have a REST API, so check for JMX port instead
112 ./wait-for-port.sh brmsgw 9989
113 ./wait-for-port.sh nexus 8081
114 ./wait-for-port.sh drools 6969
115 # wait addional 1 minute for all processes to get fully initialized and synched up
117 bash -xv config/push-policies.sh