Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Instrumental | 365a488 | 2018-11-02 09:39:54 -0500 | [diff] [blame^] | 2 | # Validate for realtime Cassandra info |
| 3 | |
| 4 | # check if outside Cluster defined... otherwise, set CASS_HOST for using expected Docker based Cass |
| 5 | if [ -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 |
| 20 | fi |
| 21 | |
Instrumental | 12f7f46 | 2018-04-23 15:43:47 -0500 | [diff] [blame] | 22 | # Pull in Variables from d.props |
Instrumental | f482ea0 | 2018-04-10 15:03:24 -0500 | [diff] [blame] | 23 | . ./d.props |
Sai Gandham | ce6a67f | 2018-04-10 14:25:35 +0000 | [diff] [blame] | 24 | |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 25 | DOCKER=${DOCKER:=docker} |
Instrumental | a05704f | 2018-09-17 13:58:02 -0500 | [diff] [blame] | 26 | |
Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame] | 27 | bash aaf.sh onap |
| 28 | |
Instrumental | 71037c3 | 2018-03-26 13:51:48 -0700 | [diff] [blame] | 29 | if [ "$1" == "" ]; then |
Instrumental | e44d2f7 | 2018-08-16 17:22:45 -0500 | [diff] [blame] | 30 | AAF_COMPONENTS=$(cat components) |
Instrumental | 71037c3 | 2018-03-26 13:51:48 -0700 | [diff] [blame] | 31 | else |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 32 | AAF_COMPONENTS="$@" |
Instrumental | 71037c3 | 2018-03-26 13:51:48 -0700 | [diff] [blame] | 33 | fi |
Instrumental | 679f142 | 2018-04-06 14:59:36 -0500 | [diff] [blame] | 34 | |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 35 | for AAF_COMPONENT in ${AAF_COMPONENTS}; do |
| 36 | case "$AAF_COMPONENT" in |
| 37 | "service") |
| 38 | PORTMAP="8100:8100" |
Instrumental | c03496d | 2018-10-19 13:59:24 -0500 | [diff] [blame] | 39 | LINKS="--link aaf_cass:cassandra " |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 40 | ;; |
| 41 | "locate") |
| 42 | PORTMAP="8095:8095" |
Instrumental | c03496d | 2018-10-19 13:59:24 -0500 | [diff] [blame] | 43 | LINKS="--link aaf_cass:cassandra " |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 44 | ;; |
| 45 | "oauth") |
| 46 | PORTMAP="8140:8140" |
Instrumental | c03496d | 2018-10-19 13:59:24 -0500 | [diff] [blame] | 47 | LINKS="--link aaf_cass:cassandra " |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 48 | ;; |
| 49 | "gui") |
| 50 | PORTMAP="8200:8200" |
| 51 | ;; |
| 52 | "cm") |
| 53 | PORTMAP="8150:8150" |
Instrumental | 93871ff | 2018-10-15 07:37:28 -0500 | [diff] [blame] | 54 | LINKS="--link aaf_cass:cassandra " |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 55 | ;; |
| 56 | "hello") |
| 57 | PORTMAP="8130:8130" |
| 58 | ;; |
| 59 | "fs") |
| 60 | PORTMAP="80:8096" |
| 61 | ;; |
| 62 | esac |
| 63 | |
| 64 | echo Starting aaf_$AAF_COMPONENT... |
| 65 | |
Instrumental | 1e3be60 | 2018-10-03 19:40:44 -0500 | [diff] [blame] | 66 | 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" |
Instrumental | 1e3be60 | 2018-10-03 19:40:44 -0500 | [diff] [blame] | 74 | done |
| 75 | |
Instrumental | 365a488 | 2018-11-02 09:39:54 -0500 | [diff] [blame^] | 76 | if [[ "$CASS_HOST" =~ ":" ]]; then |
| 77 | echo "Adding Cassandra Host $CASS_HOST" |
| 78 | ADD_HOST="$ADD_HOST --add-host=$CASS_HOST" |
| 79 | fi |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 80 | $DOCKER run \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 81 | -d \ |
| 82 | --name aaf_$AAF_COMPONENT \ |
| 83 | --hostname="${AAF_COMPONENT}.aaf.osaaf.org" \ |
Instrumental | 1e3be60 | 2018-10-03 19:40:44 -0500 | [diff] [blame] | 84 | $ADD_HOST \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 85 | ${LINKS} \ |
Instrumental | 1e3be60 | 2018-10-03 19:40:44 -0500 | [diff] [blame] | 86 | --env AAF_ENV=${AAF_ENV} \ |
| 87 | --env AAF_REGISTER_AS=${AAF_REGISTER_AS} \ |
| 88 | --env LATITUDE=${LATITUDE} \ |
| 89 | --env LONGITUDE=${LONGITUDE} \ |
Instrumental | eccc902 | 2018-10-24 13:18:57 -0500 | [diff] [blame] | 90 | --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} \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 95 | --publish $PORTMAP \ |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 96 | -v "aaf_config:$CONF_ROOT_DIR" \ |
Instrumental | e44d2f7 | 2018-08-16 17:22:45 -0500 | [diff] [blame] | 97 | ${PREFIX}${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} |
Instrumental | 71037c3 | 2018-03-26 13:51:48 -0700 | [diff] [blame] | 98 | done |