Fix test-config for DR, Champ, and Gizmo
[aai/test-config.git] / deploy_vm2.sh
1 #!/bin/bash
2
3 if [ -f "/opt/docker/docker-compose" ];
4 then
5     DOCKER_COMPOSE_CMD="/opt/docker/docker-compose -f docker-compose-db.yml"
6 else
7     DOCKER_COMPOSE_CMD="docker-compose -f docker-compose-db.yml"
8 fi
9
10 export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1);
11 export HBASE_IMAGE="${HBASE_IMAGE:-aaionap/hbase}";
12 export HBASE_VERSION="${HBASE_VERSION:-1.2.0}";
13
14 function wait_for_container() {
15
16     CONTAINER_NAME="$1";
17     START_TEXT="$2";
18
19     TIMEOUT=600
20
21     # wait for the real startup
22     AMOUNT_STARTUP=$(docker logs ${CONTAINER_NAME} 2>&1 | grep "$START_TEXT" | wc -l)
23     while [[ ${AMOUNT_STARTUP} -ne 1 ]];
24     do
25         echo "Waiting for '$CONTAINER_NAME' deployment to finish ..."
26         AMOUNT_STARTUP=$(docker logs ${CONTAINER_NAME} 2>&1 | grep "$START_TEXT" | wc -l)
27         if [ "$TIMEOUT" = "0" ];
28         then
29             echo "ERROR: $CONTAINER_NAME deployment failed."
30             exit 1
31         fi
32         let TIMEOUT-=5
33         sleep 5
34     done
35 }
36
37 docker pull cassandra:2.1;
38
39 # cleanup
40 $DOCKER_COMPOSE_CMD stop
41 $DOCKER_COMPOSE_CMD rm -f -v
42
43 CASSANDRA_CONTAINER_NAME=$($DOCKER_COMPOSE_CMD up -d aai.hbase.simpledemo.onap.org 2>&1 | grep 'Creating' | grep -v 'volume' | grep -v 'network' | awk '{ print $2; }' | head -1);
44 wait_for_container $CASSANDRA_CONTAINER_NAME 'Listening for thrift clients';
45
46 $DOCKER_COMPOSE_CMD up -d aai.elasticsearch.simpledemo.openecomp.org