blob: 9f770055dffe1147d1e4754cc7c41a6266cef9d5 [file] [log] [blame]
Instrumental4ad47632018-07-13 15:49:26 -05001#!/bin/bash
Instrumental7a1817b2018-11-05 11:11:15 -06002#########
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#
Instrumental365a4882018-11-02 09:39:54 -050021# Validate for realtime Cassandra info
22
23# check if outside Cluster defined... otherwise, set CASS_HOST for using expected Docker based Cass
24if [ -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
39fi
40
Instrumental12f7f462018-04-23 15:43:47 -050041# Pull in Variables from d.props
Instrumentalf482ea02018-04-10 15:03:24 -050042. ./d.props
Sai Gandhamce6a67f2018-04-10 14:25:35 +000043
Instrumental94053612018-10-08 11:27:18 -050044DOCKER=${DOCKER:=docker}
Instrumentala05704f2018-09-17 13:58:02 -050045
Instrumentaladb72662018-11-02 12:48:26 -050046# Running without params keeps from being TTY
Instrumentalca788dc2018-11-03 14:38:21 -050047bash ./aaf.sh
Instrumentalbc299c02018-09-25 06:42:31 -050048
Instrumental71037c32018-03-26 13:51:48 -070049if [ "$1" == "" ]; then
Instrumentale44d2f72018-08-16 17:22:45 -050050 AAF_COMPONENTS=$(cat components)
Instrumental71037c32018-03-26 13:51:48 -070051else
Instrumental4ad47632018-07-13 15:49:26 -050052 AAF_COMPONENTS="$@"
Instrumental71037c32018-03-26 13:51:48 -070053fi
Instrumental679f1422018-04-06 14:59:36 -050054
Instrumental4ad47632018-07-13 15:49:26 -050055for AAF_COMPONENT in ${AAF_COMPONENTS}; do
Instrumentalca788dc2018-11-03 14:38:21 -050056 LINKS=""
57 CMD_LINE=""
58 PORTMAP=""
Instrumental4ad47632018-07-13 15:49:26 -050059 case "$AAF_COMPONENT" in
60 "service")
61 PORTMAP="8100:8100"
Instrumentalc03496d2018-10-19 13:59:24 -050062 LINKS="--link aaf_cass:cassandra "
Instrumentalca788dc2018-11-03 14:38:21 -050063 # 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
Instrumental4ad47632018-07-13 15:49:26 -050069 ;;
70 "locate")
71 PORTMAP="8095:8095"
Instrumentalc03496d2018-10-19 13:59:24 -050072 LINKS="--link aaf_cass:cassandra "
Instrumentalca788dc2018-11-03 14:38:21 -050073 CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_locate aaf_service cd /opt/app/aaf;bin/locate"
Instrumental4ad47632018-07-13 15:49:26 -050074 ;;
75 "oauth")
76 PORTMAP="8140:8140"
Instrumentalc03496d2018-10-19 13:59:24 -050077 LINKS="--link aaf_cass:cassandra "
Instrumentalca788dc2018-11-03 14:38:21 -050078 CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_oauth aaf_service cd /opt/app/aaf;bin/oauth"
Instrumental4ad47632018-07-13 15:49:26 -050079 ;;
80 "gui")
81 PORTMAP="8200:8200"
Instrumentalca788dc2018-11-03 14:38:21 -050082 LINKS=""
83 CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_gui aaf_locate cd /opt/app/aaf;bin/gui"
Instrumental4ad47632018-07-13 15:49:26 -050084 ;;
85 "cm")
86 PORTMAP="8150:8150"
Instrumental93871ff2018-10-15 07:37:28 -050087 LINKS="--link aaf_cass:cassandra "
Instrumentalca788dc2018-11-03 14:38:21 -050088 CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_cm aaf_locate cd /opt/app/aaf;bin/cm"
Instrumental4ad47632018-07-13 15:49:26 -050089 ;;
90 "hello")
91 PORTMAP="8130:8130"
Instrumentalca788dc2018-11-03 14:38:21 -050092 LINKS=""
93 CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_hello aaf_locate cd /opt/app/aaf;bin/hello"
Instrumental4ad47632018-07-13 15:49:26 -050094 ;;
95 "fs")
96 PORTMAP="80:8096"
Instrumentalca788dc2018-11-03 14:38:21 -050097 LINKS=""
98 CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_fs aaf_locate cd /opt/app/aaf;bin/fs"
Instrumental4ad47632018-07-13 15:49:26 -050099 ;;
100 esac
101
102 echo Starting aaf_$AAF_COMPONENT...
103
Instrumental1e3be602018-10-03 19:40:44 -0500104 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"
Instrumental1e3be602018-10-03 19:40:44 -0500112 done
113
Instrumentalca788dc2018-11-03 14:38:21 -0500114 if [ ! -z "$LINKS" ] && [[ "$CASS_HOST" =~ ":" ]]; then
Instrumental365a4882018-11-02 09:39:54 -0500115 ADD_HOST="$ADD_HOST --add-host=$CASS_HOST"
116 fi
Instrumental94053612018-10-08 11:27:18 -0500117 $DOCKER run \
Instrumental4ad47632018-07-13 15:49:26 -0500118 -d \
119 --name aaf_$AAF_COMPONENT \
120 --hostname="${AAF_COMPONENT}.aaf.osaaf.org" \
Instrumental1e3be602018-10-03 19:40:44 -0500121 $ADD_HOST \
Instrumental4ad47632018-07-13 15:49:26 -0500122 ${LINKS} \
Instrumental1e3be602018-10-03 19:40:44 -0500123 --env AAF_ENV=${AAF_ENV} \
124 --env AAF_REGISTER_AS=${AAF_REGISTER_AS} \
125 --env LATITUDE=${LATITUDE} \
126 --env LONGITUDE=${LONGITUDE} \
Instrumentaleccc9022018-10-24 13:18:57 -0500127 --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} \
Instrumental4ad47632018-07-13 15:49:26 -0500132 --publish $PORTMAP \
Instrumental94053612018-10-08 11:27:18 -0500133 -v "aaf_config:$CONF_ROOT_DIR" \
Instrumentalca788dc2018-11-03 14:38:21 -0500134 -v "aaf_status:/opt/app/aaf/status" \
135 ${PREFIX}${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} \
136 $CMD_LINE
Instrumental71037c32018-03-26 13:51:48 -0700137done