3 if [ -f "/opt/docker/docker-compose" ];
5 DOCKER_COMPOSE_CMD="/opt/docker/docker-compose -f docker-compose-app.yml"
7 DOCKER_COMPOSE_CMD="docker-compose -f docker-compose-app.yml"
10 export RESOURCES_LOGS="/opt/aai/logroot/AAI-RESOURCES";
11 export TRAVERSAL_LOGS="/opt/aai/logroot/AAI-TRAVERSAL";
12 export SEARCH_LOGS="/opt/aai/logroot/AAI-SEARCH";
13 export DATA_ROUTER_LOGS="/opt/aai/logroot/AAI-DATA-ROUTER";
14 export MODEL_LOADER_LOGS="/opt/aai/logroot/AAI-MODEL-LOADER";
15 export UI_LOGS="/opt/aai/logroot/AAI-UI";
17 if [ ! -d "$RESOURCES_LOGS" ];
19 echo "Warning: Unable to find the volume directory $RESOURCES_LOGS so creating it as regular directory";
20 mkdir -p $RESOURCES_LOGS;
23 if [ ! -d "$TRAVERSAL_LOGS" ];
25 echo "Warning: Unable to find the volume directory $TRAVERSAL_LOGS so creating it as regular directory";
26 mkdir -p $TRAVERSAL_LOGS;
29 if [ ! -d "$SEARCH_LOGS" ];
31 echo "Warning: Unable to find the volume directory $SEARCH_LOGS so creating it as regular directory";
32 mkdir -p $SEARCH_LOGS;
35 if [ ! -d "$DATA_ROUTER_LOGS" ];
37 echo "Warning: Unable to find the volume directory $DATA_ROUTER_LOGS so creating it as regular directory";
38 mkdir -p $DATA_ROUTER_LOGS;
41 if [ ! -d "$MODEL_LOADER_LOGS" ];
43 echo "Warning: Unable to find the volume directory $MODEL_LOADER_LOGS so creating it as regular directory";
44 mkdir -p $MODEL_LOADER_LOGS;
47 if [ ! -d "$UI_LOGS" ];
49 echo "Warning: Unable to find the volume directory $UI_LOGS so creating it as regular directory";
53 export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1);
54 export DOCKER_REGISTRY="${DOCKER_REGISTRY:-localhost:5000}";
55 export AAI_HAPROXY_IMAGE="${AAI_HAPROXY_IMAGE:-aaionap/haproxy}";
57 NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt)
58 NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt)
59 NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt)
60 DMAAP_TOPIC=$(cat /opt/config/dmaap_topic.txt)
61 DOCKER_IMAGE_VERSION=$(cat /opt/config/docker_version.txt)
62 DOCKER_REGISTRY=${NEXUS_DOCKER_REPO}
64 docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
66 function wait_for_container() {
73 # wait for the real startup
74 AMOUNT_STARTUP=$(docker logs ${CONTAINER_NAME} 2>&1 | grep "$START_TEXT" | wc -l)
75 while [[ ${AMOUNT_STARTUP} -ne 1 ]];
77 echo "Waiting for '$CONTAINER_NAME' deployment to finish ..."
78 AMOUNT_STARTUP=$(docker logs ${CONTAINER_NAME} 2>&1 | grep "$START_TEXT" | wc -l)
79 if [ "$TIMEOUT" = "0" ];
81 echo "ERROR: $CONTAINER_NAME deployment failed."
89 if [ ! -d "/opt/message-router" ]; then
91 git clone http://gerrit.onap.org/r/dcae/demo/startup/message-router && \
92 cd message-router && \
96 docker pull ${DOCKER_REGISTRY}/openecomp/aai-resources:${DOCKER_IMAGE_VERSION};
97 docker tag $DOCKER_REGISTRY/openecomp/aai-resources:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/openecomp/aai-resources:latest;
99 docker pull ${DOCKER_REGISTRY}/openecomp/aai-traversal:${DOCKER_IMAGE_VERSION};
100 docker tag $DOCKER_REGISTRY/openecomp/aai-traversal:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/openecomp/aai-traversal:latest;
102 docker pull ${DOCKER_REGISTRY}/openecomp/search-data-service:${DOCKER_IMAGE_VERSION};
103 docker tag $DOCKER_REGISTRY/openecomp/search-data-service:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/openecomp/search-data-service:latest;
105 docker pull ${DOCKER_REGISTRY}/openecomp/data-router:${DOCKER_IMAGE_VERSION};
106 docker tag $DOCKER_REGISTRY/openecomp/data-router:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/openecomp/data-router:latest;
108 docker pull ${DOCKER_REGISTRY}/openecomp/model-loader:${DOCKER_IMAGE_VERSION};
109 docker tag $DOCKER_REGISTRY/openecomp/model-loader:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/openecomp/model-loader:latest;
111 docker pull ${DOCKER_REGISTRY}/openecomp/sparky-be:${DOCKER_IMAGE_VERSION};
112 docker tag $DOCKER_REGISTRY/openecomp/sparky-be:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/openecomp/sparky-be:latest;
115 $DOCKER_COMPOSE_CMD stop
116 $DOCKER_COMPOSE_CMD rm -f -v
118 USER_ID=$(docker run -it --rm --entrypoint=id $DOCKER_REGISTRY/openecomp/aai-resources -u | sed 's/[^0-9]//g')
119 GROUP_ID=$(docker run -it --rm --entrypoint=id $DOCKER_REGISTRY/openecomp/aai-resources -g | sed 's/[^0-9]//g')
121 chown -R $USER_ID:$GROUP_ID $RESOURCES_LOGS || {
123 echo "Unable to change ownership of $RESOURCE_LOGS to $USER_ID:$GROUP_ID" >> /var/tmp/deploy_vm1.log;
124 echo "Trying with sudo now" >> /var/tmp/deploy_vm1.log;
126 chown -R 999:999 $RESOURCES_LOGS;
128 if [ $? -ne 0 ]; then
129 echo "Unable to change ownership of $RESOURCE_LOGS to 999:999 as well" >> /var/tmp/deploy_vm1.log;
130 sudo chown -R 999:999 $RESOURCE_LOGS;
135 chown -R $USER_ID:$GROUP_ID $TRAVERSAL_LOGS || {
137 echo "Unable to change ownership of $TRAVERSAL_LOGS to $USER_ID:$GROUP_ID" >> /var/tmp/deploy_vm1.log;
138 echo "Trying with sudo now" >> /var/tmp/deploy_vm1.log;
140 chown -R 999:999 $RESOURCES_LOGS;
142 if [ $? -ne 0 ]; then
143 echo "Unable to change ownership of $TRAVERSAL_LOGS to 999:999 as well" >> /var/tmp/deploy_vm1.log;
144 sudo chown -R 999:999 $TRAVERSAL_LOGS;
148 $DOCKER_COMPOSE_CMD up -d sparky-be
150 RESOURCES_CONTAINER_NAME=$($DOCKER_COMPOSE_CMD up -d aai-resources.api.simpledemo.openecomp.org 2>&1 | grep 'Creating' | grep -v 'volume' | grep -v 'network' | awk '{ print $2; }' | head -1);
151 wait_for_container $RESOURCES_CONTAINER_NAME '0.0.0.0:8447';
153 GRAPH_CONTAINER_NAME=$($DOCKER_COMPOSE_CMD up -d aai-traversal.api.simpledemo.openecomp.org 2>&1 | grep 'Creating' | awk '{ print $2; }' | head -1);
154 wait_for_container $GRAPH_CONTAINER_NAME '0.0.0.0:8446';
157 $DOCKER_COMPOSE_CMD up -d aai.api.simpledemo.openecomp.org
159 docker exec -it $GRAPH_CONTAINER_NAME "/opt/app/aai-traversal/scripts/install/updateQueryData.sh";
161 $DOCKER_COMPOSE_CMD up -d model-loader datarouter