blob: 34041c7a9df6a9d046ee370733acd3d095e40a03 [file] [log] [blame]
Pamela Dragoshd1728dc2017-02-14 19:57:17 -05001#!/bin/bash
2
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).
7
8container=$1
9
10case $container in
11pap)
Ravindra Bakkamanthalabe9c8ae2017-05-24 13:04:17 -040012 comps="base pap paplp console mysql elk"
Pamela Dragoshd1728dc2017-02-14 19:57:17 -050013 ;;
14pdp)
15 comps="base pdp pdplp"
16 ;;
Pamela Dragoshd1728dc2017-02-14 19:57:17 -050017brmsgw)
18 comps="base brmsgw"
19 ;;
20*)
ITSERVICES\rb7147b150eba2017-05-09 13:54:45 -040021 echo "Usage: do-start.sh pap|pdp|brmsgw" >&2
Pamela Dragoshd1728dc2017-02-14 19:57:17 -050022 exit 1
23esac
24
25
26# skip installation if build.info file is present (restarting an existing container)
27if [[ -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
30
31else
32 if [[ -d config ]]; then
33 cp config/*.conf .
34 fi
35
36 for comp in $comps; do
37 echo "Installing component: $comp"
38 ./docker-install.sh --install $comp
39 done
40 for comp in $comps; do
41 echo "Configuring component: $comp"
42 ./docker-install.sh --configure $comp
43 done
44
45 . /opt/app/policy/etc/profile.d/env.sh
46
47 # install keystore
48 #changed to use http instead of http, so keystore no longer needed
49 #cp config/policy-keystore.jks $POLICY_HOME/etc/ssl/policy-keystore
50
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
55 fi
56
57 if [[ $container == pap ]]; then
58 # wait for DB up
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
65 fi
66
67fi
68
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)
71if [[ $container == pap ]]; then
72 # we may have already done this above, but doesn't hurt to repeat
73 ./wait-for-port.sh mariadb 3306
74else
75 ./wait-for-port.sh pap 9091
76fi
77
78policy.sh start
79
ITSERVICES\rb7147b150eba2017-05-09 13:54:45 -040080# on pap, wait for pap, pdp, brmsgw, and nexus up,
Pamela Dragoshd1728dc2017-02-14 19:57:17 -050081# then push the initial default policies
82if [[ $container == pap ]]; then
83 ./wait-for-port.sh pap 9091
84 ./wait-for-port.sh pdp 8081
Pamela Dragoshd1728dc2017-02-14 19:57:17 -050085 # 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 addional 1 minute for all processes to get fully initialized and synched up
89 sleep 60
90 bash config/push-policies.sh
91fi
92
93sleep 1000d