3 # Script to configure and start the Policy components that are to run in the designated container,
4 # It is intended to be used as the entrypoint in the Dockerfile, so the last statement of the
5 # script just goes into a long sleep so that the script does not exit (which would cause the
6 # container to be torn down).
12 comps="base pap paplp console mysql elk"
15 comps="base pdp pdplp"
21 echo "Usage: do-start.sh pap|pdp|brmsgw" >&2
26 # skip installation if build.info file is present (restarting an existing container)
27 if [[ -f /opt/app/policy/etc/build.info ]]; then
28 echo "Found existing installation, will not reinstall"
29 . /opt/app/policy/etc/profile.d/env.sh
32 if [[ -d config ]]; then
36 for comp in $comps; do
37 echo "Installing component: $comp"
38 ./docker-install.sh --install $comp
40 for comp in $comps; do
41 echo "Configuring component: $comp"
42 ./docker-install.sh --configure $comp
45 . /opt/app/policy/etc/profile.d/env.sh
47 # install policy keystore
48 mkdir -p $POLICY_HOME/etc/ssl
49 cp config/policy-keystore $POLICY_HOME/etc/ssl
51 if [[ -f config/$container-tweaks.sh ]] ; then
52 # file may not be executable; running it as an
53 # argument to bash avoids needing execute perms.
54 bash config/$container-tweaks.sh
57 if [[ $container == pap ]]; then
59 ./wait-for-port.sh mariadb 3306
60 # now that DB is up, invoke database upgrade
61 # (which does nothing if the db is already up-to-date)
62 dbuser=$(echo $(grep '^JDBC_USER=' base.conf | cut -f2 -d=))
63 dbpw=$(echo $(grep '^JDBC_PASSWORD=' base.conf | cut -f2 -d=))
64 db_upgrade_remote.sh $dbuser $dbpw mariadb
69 # pap needs to wait for mariadb up before starting;
70 # others need to wait for pap up (in case it had to do db upgrade)
71 if [[ $container == pap ]]; then
72 # we may have already done this above, but doesn't hurt to repeat
73 ./wait-for-port.sh mariadb 3306
75 ./wait-for-port.sh pap 9091
80 # on pap, wait for pap, pdp, brmsgw, nexus and drools up,
81 # then push the initial default policies
82 if [[ $container == pap ]]; then
83 ./wait-for-port.sh pap 9091
84 ./wait-for-port.sh pdp 8081
85 # brmsgw doesn't have a REST API, so check for JMX port instead
86 ./wait-for-port.sh brmsgw 9989
87 ./wait-for-port.sh nexus 8081
88 ./wait-for-port.sh drools 6969
89 # wait addional 1 minute for all processes to get fully initialized and synched up
91 bash -xv config/push-policies.sh