blob: 1b4423684ead9f57669b15a2734ec014b33ee5a7 [file] [log] [blame]
Instrumental4ad47632018-07-13 15:49:26 -05001#!/bin/bash
Instrumental365a4882018-11-02 09:39:54 -05002# Validate for realtime Cassandra info
3
4# check if outside Cluster defined... otherwise, set CASS_HOST for using expected Docker based Cass
5if [ -z "$(grep -e '^CASS_CLUSTER=.*' d.props)" ]; then
6 if [ "$(uname)" = "Darwin" ]; then
7 SED="sed -i .bak"
8 else
9 SED="sed -i"
10 fi
11
12 CASSANDRA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' aaf_cass)
13 if [ -z "$(grep -e '^CASS_HOST.*' d.props)" ]; then
14 $SED "s/# CASS_HOST=.*/CASS_HOST=cass.aaf.osaaf.org:$CASSANDRA_IP/" d.props
15 else
16 $SED "s/CASS_HOST=.*/CASS_HOST=cass.aaf.osaaf.org:$CASSANDRA_IP/" d.props
17 fi
18 echo "Updated d.props for CASSANDRA Name/IP"
19 grep -e '^CASS_HOST.*' d.props
20fi
21
Instrumental12f7f462018-04-23 15:43:47 -050022# Pull in Variables from d.props
Instrumentalf482ea02018-04-10 15:03:24 -050023. ./d.props
Sai Gandhamce6a67f2018-04-10 14:25:35 +000024
Instrumental94053612018-10-08 11:27:18 -050025DOCKER=${DOCKER:=docker}
Instrumentala05704f2018-09-17 13:58:02 -050026
Instrumentalbc299c02018-09-25 06:42:31 -050027bash aaf.sh onap
28
Instrumental71037c32018-03-26 13:51:48 -070029if [ "$1" == "" ]; then
Instrumentale44d2f72018-08-16 17:22:45 -050030 AAF_COMPONENTS=$(cat components)
Instrumental71037c32018-03-26 13:51:48 -070031else
Instrumental4ad47632018-07-13 15:49:26 -050032 AAF_COMPONENTS="$@"
Instrumental71037c32018-03-26 13:51:48 -070033fi
Instrumental679f1422018-04-06 14:59:36 -050034
Instrumental4ad47632018-07-13 15:49:26 -050035for AAF_COMPONENT in ${AAF_COMPONENTS}; do
36 case "$AAF_COMPONENT" in
37 "service")
38 PORTMAP="8100:8100"
Instrumentalc03496d2018-10-19 13:59:24 -050039 LINKS="--link aaf_cass:cassandra "
Instrumental4ad47632018-07-13 15:49:26 -050040 ;;
41 "locate")
42 PORTMAP="8095:8095"
Instrumentalc03496d2018-10-19 13:59:24 -050043 LINKS="--link aaf_cass:cassandra "
Instrumental4ad47632018-07-13 15:49:26 -050044 ;;
45 "oauth")
46 PORTMAP="8140:8140"
Instrumentalc03496d2018-10-19 13:59:24 -050047 LINKS="--link aaf_cass:cassandra "
Instrumental4ad47632018-07-13 15:49:26 -050048 ;;
49 "gui")
50 PORTMAP="8200:8200"
51 ;;
52 "cm")
53 PORTMAP="8150:8150"
Instrumental93871ff2018-10-15 07:37:28 -050054 LINKS="--link aaf_cass:cassandra "
Instrumental4ad47632018-07-13 15:49:26 -050055 ;;
56 "hello")
57 PORTMAP="8130:8130"
58 ;;
59 "fs")
60 PORTMAP="80:8096"
61 ;;
62 esac
63
64 echo Starting aaf_$AAF_COMPONENT...
65
Instrumental1e3be602018-10-03 19:40:44 -050066 if [ -n "$AAF_REGISTER_AS" ] && [ "$HOSTNAME" != "$AAF_REGISTER_AS" ]; then
67 AH_ROOT="$HOSTNAME $AAF_REGISTER_AS"
68 else
69 AH_ROOT="$HOSTNAME"
70 fi
71
72 for A in aaf.osaaf.org $AH_ROOT; do
73 ADD_HOST="$ADD_HOST --add-host=$A:$HOST_IP"
Instrumental1e3be602018-10-03 19:40:44 -050074 done
75
Instrumental365a4882018-11-02 09:39:54 -050076 if [[ "$CASS_HOST" =~ ":" ]]; then
77 echo "Adding Cassandra Host $CASS_HOST"
78 ADD_HOST="$ADD_HOST --add-host=$CASS_HOST"
79 fi
Instrumental94053612018-10-08 11:27:18 -050080 $DOCKER run \
Instrumental4ad47632018-07-13 15:49:26 -050081 -d \
82 --name aaf_$AAF_COMPONENT \
83 --hostname="${AAF_COMPONENT}.aaf.osaaf.org" \
Instrumental1e3be602018-10-03 19:40:44 -050084 $ADD_HOST \
Instrumental4ad47632018-07-13 15:49:26 -050085 ${LINKS} \
Instrumental1e3be602018-10-03 19:40:44 -050086 --env AAF_ENV=${AAF_ENV} \
87 --env AAF_REGISTER_AS=${AAF_REGISTER_AS} \
88 --env LATITUDE=${LATITUDE} \
89 --env LONGITUDE=${LONGITUDE} \
Instrumentaleccc9022018-10-24 13:18:57 -050090 --env CASS_HOST=${CASS_HOST} \
91 --env CASSANDRA_CLUSTER=${CASSANDRA_CLUSTER} \
92 --env CASSANDRA_USER=${CASSANDRA_USER} \
93 --env CASSANDRA_PASSWORD=${CASSANDRA_PASSWORD} \
94 --env CASSANDRA_PORT=${CASSANDRA_PORT} \
Instrumental4ad47632018-07-13 15:49:26 -050095 --publish $PORTMAP \
Instrumental94053612018-10-08 11:27:18 -050096 -v "aaf_config:$CONF_ROOT_DIR" \
Instrumentale44d2f72018-08-16 17:22:45 -050097 ${PREFIX}${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION}
Instrumental71037c32018-03-26 13:51:48 -070098done