Pamela Dragosh | d1728dc | 2017-02-14 19:57:17 -0500 | [diff] [blame] | 1 | #!/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 | |
| 8 | container=$1 |
| 9 | |
| 10 | case $container in |
| 11 | pap) |
Ravindra Bakkamanthala | be9c8ae | 2017-05-24 13:04:17 -0400 | [diff] [blame] | 12 | comps="base pap paplp console mysql elk" |
Pamela Dragosh | d1728dc | 2017-02-14 19:57:17 -0500 | [diff] [blame] | 13 | ;; |
| 14 | pdp) |
| 15 | comps="base pdp pdplp" |
| 16 | ;; |
Pamela Dragosh | d1728dc | 2017-02-14 19:57:17 -0500 | [diff] [blame] | 17 | brmsgw) |
| 18 | comps="base brmsgw" |
| 19 | ;; |
| 20 | *) |
ITSERVICES\rb7147 | b150eba | 2017-05-09 13:54:45 -0400 | [diff] [blame] | 21 | echo "Usage: do-start.sh pap|pdp|brmsgw" >&2 |
Pamela Dragosh | d1728dc | 2017-02-14 19:57:17 -0500 | [diff] [blame] | 22 | exit 1 |
| 23 | esac |
| 24 | |
| 25 | |
| 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 |
| 30 | |
| 31 | else |
| 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 | |
| 67 | fi |
| 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) |
| 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 |
| 74 | else |
| 75 | ./wait-for-port.sh pap 9091 |
| 76 | fi |
| 77 | |
| 78 | policy.sh start |
| 79 | |
ITSERVICES\rb7147 | b150eba | 2017-05-09 13:54:45 -0400 | [diff] [blame] | 80 | # on pap, wait for pap, pdp, brmsgw, and nexus up, |
Pamela Dragosh | d1728dc | 2017-02-14 19:57:17 -0500 | [diff] [blame] | 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 |
Pamela Dragosh | d1728dc | 2017-02-14 19:57:17 -0500 | [diff] [blame] | 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 addional 1 minute for all processes to get fully initialized and synched up |
| 89 | sleep 60 |
| 90 | bash config/push-policies.sh |
| 91 | fi |
| 92 | |
| 93 | sleep 1000d |