Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Instrumental | 7a1817b | 2018-11-05 11:11:15 -0600 | [diff] [blame] | 2 | ######### |
| 3 | # ============LICENSE_START==================================================== |
| 4 | # org.onap.aaf |
| 5 | # =========================================================================== |
| 6 | # Copyright (c) 2017 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 |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 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==================================================== |
| 20 | # |
Instrumental | 365a488 | 2018-11-02 09:39:54 -0500 | [diff] [blame] | 21 | # Validate for realtime Cassandra info |
| 22 | |
| 23 | # check if outside Cluster defined... otherwise, set CASS_HOST for using expected Docker based Cass |
| 24 | if [ -z "$(grep -e '^CASS_CLUSTER=.*' d.props)" ]; then |
| 25 | if [ "$(uname)" = "Darwin" ]; then |
| 26 | SED="sed -i .bak" |
| 27 | else |
| 28 | SED="sed -i" |
| 29 | fi |
| 30 | |
| 31 | CASSANDRA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' aaf_cass) |
| 32 | if [ -z "$(grep -e '^CASS_HOST.*' d.props)" ]; then |
| 33 | $SED "s/# CASS_HOST=.*/CASS_HOST=cass.aaf.osaaf.org:$CASSANDRA_IP/" d.props |
| 34 | else |
| 35 | $SED "s/CASS_HOST=.*/CASS_HOST=cass.aaf.osaaf.org:$CASSANDRA_IP/" d.props |
| 36 | fi |
| 37 | echo "Updated d.props for CASSANDRA Name/IP" |
| 38 | grep -e '^CASS_HOST.*' d.props |
| 39 | fi |
| 40 | |
Instrumental | 12f7f46 | 2018-04-23 15:43:47 -0500 | [diff] [blame] | 41 | # Pull in Variables from d.props |
Instrumental | f482ea0 | 2018-04-10 15:03:24 -0500 | [diff] [blame] | 42 | . ./d.props |
Sai Gandham | ce6a67f | 2018-04-10 14:25:35 +0000 | [diff] [blame] | 43 | |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 44 | DOCKER=${DOCKER:=docker} |
Instrumental | a05704f | 2018-09-17 13:58:02 -0500 | [diff] [blame] | 45 | |
Instrumental | adb7266 | 2018-11-02 12:48:26 -0500 | [diff] [blame] | 46 | # Running without params keeps from being TTY |
Instrumental | ca788dc | 2018-11-03 14:38:21 -0500 | [diff] [blame] | 47 | bash ./aaf.sh |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 48 | |
Instrumental | 71037c3 | 2018-03-26 13:51:48 -0700 | [diff] [blame] | 49 | if [ "$1" == "" ]; then |
Instrumental | e44d2f7 | 2018-08-16 17:22:45 -0500 | [diff] [blame] | 50 | AAF_COMPONENTS=$(cat components) |
Instrumental | 71037c3 | 2018-03-26 13:51:48 -0700 | [diff] [blame] | 51 | else |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 52 | AAF_COMPONENTS="$@" |
Instrumental | 71037c3 | 2018-03-26 13:51:48 -0700 | [diff] [blame] | 53 | fi |
Instrumental | 679f142 | 2018-04-06 14:59:36 -0500 | [diff] [blame] | 54 | |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 55 | for AAF_COMPONENT in ${AAF_COMPONENTS}; do |
Instrumental | ca788dc | 2018-11-03 14:38:21 -0500 | [diff] [blame] | 56 | LINKS="" |
| 57 | CMD_LINE="" |
| 58 | PORTMAP="" |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 59 | case "$AAF_COMPONENT" in |
| 60 | "service") |
| 61 | PORTMAP="8100:8100" |
Instrumental | c03496d | 2018-10-19 13:59:24 -0500 | [diff] [blame] | 62 | LINKS="--link aaf_cass:cassandra " |
Instrumental | ca788dc | 2018-11-03 14:38:21 -0500 | [diff] [blame] | 63 | # CASS_HOST is for Container based Cassadra |
| 64 | if [ -z "$CASS_HOST" ]; then |
| 65 | CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_service sleep 0 cd /opt/app/aaf;bin/service" |
| 66 | else |
| 67 | CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_service aaf_cass cd /opt/app/aaf;bin/service" |
| 68 | fi |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 69 | ;; |
| 70 | "locate") |
| 71 | PORTMAP="8095:8095" |
Instrumental | c03496d | 2018-10-19 13:59:24 -0500 | [diff] [blame] | 72 | LINKS="--link aaf_cass:cassandra " |
Instrumental | ca788dc | 2018-11-03 14:38:21 -0500 | [diff] [blame] | 73 | CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_locate aaf_service cd /opt/app/aaf;bin/locate" |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 74 | ;; |
| 75 | "oauth") |
| 76 | PORTMAP="8140:8140" |
Instrumental | c03496d | 2018-10-19 13:59:24 -0500 | [diff] [blame] | 77 | LINKS="--link aaf_cass:cassandra " |
Instrumental | ca788dc | 2018-11-03 14:38:21 -0500 | [diff] [blame] | 78 | CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_oauth aaf_service cd /opt/app/aaf;bin/oauth" |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 79 | ;; |
| 80 | "gui") |
| 81 | PORTMAP="8200:8200" |
Instrumental | ca788dc | 2018-11-03 14:38:21 -0500 | [diff] [blame] | 82 | LINKS="" |
| 83 | CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_gui aaf_locate cd /opt/app/aaf;bin/gui" |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 84 | ;; |
| 85 | "cm") |
| 86 | PORTMAP="8150:8150" |
Instrumental | 93871ff | 2018-10-15 07:37:28 -0500 | [diff] [blame] | 87 | LINKS="--link aaf_cass:cassandra " |
Instrumental | ca788dc | 2018-11-03 14:38:21 -0500 | [diff] [blame] | 88 | CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_cm aaf_locate cd /opt/app/aaf;bin/cm" |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 89 | ;; |
| 90 | "hello") |
| 91 | PORTMAP="8130:8130" |
Instrumental | ca788dc | 2018-11-03 14:38:21 -0500 | [diff] [blame] | 92 | LINKS="" |
| 93 | CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_hello aaf_locate cd /opt/app/aaf;bin/hello" |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 94 | ;; |
| 95 | "fs") |
| 96 | PORTMAP="80:8096" |
Instrumental | ca788dc | 2018-11-03 14:38:21 -0500 | [diff] [blame] | 97 | LINKS="" |
| 98 | CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_fs aaf_locate cd /opt/app/aaf;bin/fs" |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 99 | ;; |
| 100 | esac |
| 101 | |
| 102 | echo Starting aaf_$AAF_COMPONENT... |
| 103 | |
Instrumental | 1e3be60 | 2018-10-03 19:40:44 -0500 | [diff] [blame] | 104 | if [ -n "$AAF_REGISTER_AS" ] && [ "$HOSTNAME" != "$AAF_REGISTER_AS" ]; then |
| 105 | AH_ROOT="$HOSTNAME $AAF_REGISTER_AS" |
| 106 | else |
| 107 | AH_ROOT="$HOSTNAME" |
| 108 | fi |
| 109 | |
| 110 | for A in aaf.osaaf.org $AH_ROOT; do |
| 111 | ADD_HOST="$ADD_HOST --add-host=$A:$HOST_IP" |
Instrumental | 1e3be60 | 2018-10-03 19:40:44 -0500 | [diff] [blame] | 112 | done |
| 113 | |
Instrumental | ca788dc | 2018-11-03 14:38:21 -0500 | [diff] [blame] | 114 | if [ ! -z "$LINKS" ] && [[ "$CASS_HOST" =~ ":" ]]; then |
Instrumental | 365a488 | 2018-11-02 09:39:54 -0500 | [diff] [blame] | 115 | ADD_HOST="$ADD_HOST --add-host=$CASS_HOST" |
| 116 | fi |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 117 | $DOCKER run \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 118 | -d \ |
| 119 | --name aaf_$AAF_COMPONENT \ |
| 120 | --hostname="${AAF_COMPONENT}.aaf.osaaf.org" \ |
Instrumental | 1e3be60 | 2018-10-03 19:40:44 -0500 | [diff] [blame] | 121 | $ADD_HOST \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 122 | ${LINKS} \ |
Instrumental | 1e3be60 | 2018-10-03 19:40:44 -0500 | [diff] [blame] | 123 | --env AAF_ENV=${AAF_ENV} \ |
| 124 | --env AAF_REGISTER_AS=${AAF_REGISTER_AS} \ |
| 125 | --env LATITUDE=${LATITUDE} \ |
| 126 | --env LONGITUDE=${LONGITUDE} \ |
Instrumental | eccc902 | 2018-10-24 13:18:57 -0500 | [diff] [blame] | 127 | --env CASS_HOST=${CASS_HOST} \ |
| 128 | --env CASSANDRA_CLUSTER=${CASSANDRA_CLUSTER} \ |
| 129 | --env CASSANDRA_USER=${CASSANDRA_USER} \ |
| 130 | --env CASSANDRA_PASSWORD=${CASSANDRA_PASSWORD} \ |
| 131 | --env CASSANDRA_PORT=${CASSANDRA_PORT} \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 132 | --publish $PORTMAP \ |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 133 | -v "aaf_config:$CONF_ROOT_DIR" \ |
Instrumental | ca788dc | 2018-11-03 14:38:21 -0500 | [diff] [blame] | 134 | -v "aaf_status:/opt/app/aaf/status" \ |
| 135 | ${PREFIX}${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} \ |
| 136 | $CMD_LINE |
Instrumental | 71037c3 | 2018-03-26 13:51:48 -0700 | [diff] [blame] | 137 | done |