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";
16 export CHAMP_LOGS="/opt/aai/logroot/AAI-CHAMP-SERVICE";
17 export CRUD_LOGS="/opt/aai/logroot/AAI-CRUD-SERVICE";
18 export BABEL_LOGS="/opt/aai/logroot/AAI-BAS";
20 if [ ! -d "$RESOURCES_LOGS" ];
22 echo "Warning: Unable to find the volume directory $RESOURCES_LOGS so creating it as regular directory";
23 mkdir -p $RESOURCES_LOGS;
26 if [ ! -d "$TRAVERSAL_LOGS" ];
28 echo "Warning: Unable to find the volume directory $TRAVERSAL_LOGS so creating it as regular directory";
29 mkdir -p $TRAVERSAL_LOGS;
32 if [ ! -d "$SEARCH_LOGS" ];
34 echo "Warning: Unable to find the volume directory $SEARCH_LOGS so creating it as regular directory";
35 mkdir -p $SEARCH_LOGS;
38 if [ ! -d "$DATA_ROUTER_LOGS" ];
40 echo "Warning: Unable to find the volume directory $DATA_ROUTER_LOGS so creating it as regular directory";
41 mkdir -p $DATA_ROUTER_LOGS;
44 if [ ! -d "$MODEL_LOADER_LOGS" ];
46 echo "Warning: Unable to find the volume directory $MODEL_LOADER_LOGS so creating it as regular directory";
47 mkdir -p $MODEL_LOADER_LOGS;
50 if [ ! -d "$UI_LOGS" ];
52 echo "Warning: Unable to find the volume directory $UI_LOGS so creating it as regular directory";
56 if [ ! -d "$CHAMP_LOGS" ];
58 echo "Warning: Unable to find the volume directory $CHAMP_LOGS so creating it as regular directory";
62 if [ ! -d "$CRUD_LOGS" ];
64 echo "Warning: Unable to find the volume directory $CRUD_LOGS so creating it as regular directory";
68 if [ ! -d "$BABEL_LOGS" ];
70 echo "Warning: Unable to find the volume directory $BABEL_LOGS so creating it as regular directory";
74 export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1);
75 export DOCKER_REGISTRY="${DOCKER_REGISTRY:-localhost:5000}";
76 export AAI_HAPROXY_IMAGE="${AAI_HAPROXY_IMAGE:-aaionap/haproxy}";
77 export AAI_HAPROXY_VERSION="${AAI_HAPROXY_VERSION:-1.2.3}";
79 NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt)
80 NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt)
81 NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt)
82 DMAAP_TOPIC=$(cat /opt/config/dmaap_topic.txt)
83 DOCKER_IMAGE_VERSION=$(cat /opt/config/docker_version.txt)
84 DOCKER_REGISTRY=${NEXUS_DOCKER_REPO}
86 docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
88 function wait_for_container() {
95 # wait for the real startup
96 AMOUNT_STARTUP=$(docker logs ${CONTAINER_NAME} 2>&1 | grep "$START_TEXT" | wc -l)
97 while [[ ${AMOUNT_STARTUP} -ne 1 ]];
99 echo "Waiting for '$CONTAINER_NAME' deployment to finish ..."
100 AMOUNT_STARTUP=$(docker logs ${CONTAINER_NAME} 2>&1 | grep "$START_TEXT" | wc -l)
101 if [ "$TIMEOUT" = "0" ];
103 echo "ERROR: $CONTAINER_NAME deployment failed."
111 function check_if_user_exists(){
115 if [ -z "$user_id" ]; then
116 echo "Needs to provide at least one argument for check_if_user_exists func";
120 id -u ${user_id} > /dev/null 2>&1 && {
127 docker pull ${DOCKER_REGISTRY}/onap/aai-resources:${DOCKER_IMAGE_VERSION};
128 docker tag $DOCKER_REGISTRY/onap/aai-resources:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/onap/aai-resources:latest;
130 docker pull ${DOCKER_REGISTRY}/onap/aai-traversal:${DOCKER_IMAGE_VERSION};
131 docker tag $DOCKER_REGISTRY/onap/aai-traversal:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/onap/aai-traversal:latest;
133 docker pull ${DOCKER_REGISTRY}/onap/search-data-service:${DOCKER_IMAGE_VERSION};
134 docker tag $DOCKER_REGISTRY/onap/search-data-service:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/onap/search-data-service:latest;
136 docker pull ${DOCKER_REGISTRY}/onap/data-router:${DOCKER_IMAGE_VERSION};
137 docker tag $DOCKER_REGISTRY/onap/data-router:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/onap/data-router:latest;
139 docker pull ${DOCKER_REGISTRY}/onap/model-loader:${DOCKER_IMAGE_VERSION};
140 docker tag $DOCKER_REGISTRY/onap/model-loader:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/onap/model-loader:latest;
142 docker pull ${DOCKER_REGISTRY}/onap/sparky-be:${DOCKER_IMAGE_VERSION};
143 docker tag $DOCKER_REGISTRY/onap/sparky-be:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/onap/sparky-be:latest;
145 docker pull ${DOCKER_REGISTRY}/onap/champ:${DOCKER_IMAGE_VERSION};
146 docker tag $DOCKER_REGISTRY/onap/champ:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/onap/champ:latest;
148 docker pull ${DOCKER_REGISTRY}/onap/gizmo:${DOCKER_IMAGE_VERSION};
149 docker tag $DOCKER_REGISTRY/onap/gizmo:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/onap/gizmo:latest;
151 docker pull ${DOCKER_REGISTRY}/onap/babel:${DOCKER_IMAGE_VERSION};
152 docker tag $DOCKER_REGISTRY/onap/babel:$DOCKER_IMAGE_VERSION $DOCKER_REGISTRY/onap/babel:latest;
155 $DOCKER_COMPOSE_CMD stop
156 $DOCKER_COMPOSE_CMD rm -f -v
159 USER_EXISTS=$(check_if_user_exists aaiadmin);
161 if [ "${USER_EXISTS}" -eq 0 ]; then
163 export GROUP_ID=9000;
165 export USER_ID=$(id -u aaiadmin);
166 export GROUP_ID=$(id -g aaiadmin);
169 chown -R $USER_ID:$USER_ID $RESOURCE_LOGS $TRAVERSAL_LOGS;
170 chown -R 341790:492381 $BABEL_LOGS;
172 $DOCKER_COMPOSE_CMD run --rm aai-resources.api.simpledemo.onap.org createDBSchema.sh
174 RESOURCES_CONTAINER_NAME=$($DOCKER_COMPOSE_CMD up -d aai-resources.api.simpledemo.onap.org 2>&1 | grep 'Creating' | grep -v 'volume' | grep -v 'network' | awk '{ print $2; }' | head -1);
175 wait_for_container $RESOURCES_CONTAINER_NAME 'Resources Microservice Started';
177 # Deploy haproxy and traversal at the same time for traversal to make updateQuery against resources using haproxy
178 $DOCKER_COMPOSE_CMD up -d aai-traversal.api.simpledemo.onap.org aai.api.simpledemo.onap.org
182 $DOCKER_COMPOSE_CMD run --rm aai-traversal.api.simpledemo.onap.org install/updateQueryData.sh
184 $DOCKER_COMPOSE_CMD up -d sparky-be
186 $DOCKER_COMPOSE_CMD up -d model-loader datarouter aai.searchservice.simpledemo.openecomp.org
188 $DOCKER_COMPOSE_CMD up -d champ-service
190 $DOCKER_COMPOSE_CMD up -d crud-service
192 $DOCKER_COMPOSE_CMD up -d babel
194 echo "A&AI Microservices are successfully started";
196 crontab < /opt/test-config/aaicrontab