Add the "@Override" annotation above this method signature - SonarFix
[aaf/authz.git] / auth / docker / drun.sh
1 #!/bin/bash
2 #########
3 #  ============LICENSE_START====================================================
4 #  org.onap.aaf
5 #  ===========================================================================
6 #  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
7 #  ===========================================================================
8 #  Licensed under the Apache License, Version 2.0 (the "License");
9 #  you may not use this file except in compliance with the License.
10 #  You may obtain a copy of the License at
11 #
12 #       http://www.apache.org/licenses/LICENSE-2.0
13 #
14 #  Unless required by applicable law or agreed to in writing, software
15 #  distributed under the License is distributed on an "AS IS" BASIS,
16 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 #  See the License for the specific language governing permissions and
18 #  limitations under the License.
19 #  ============LICENSE_END====================================================
20 #
21 # Pull in Variables from d.props
22 . ./d.props
23
24 CASSANDRA_CLUSTER=${CASSANDRA_CLUSTER:=$CASSANDRA_DOCKER}
25
26 DOCKER=${DOCKER:=docker}
27
28 # Running without params keeps from being TTY
29 bash ./aaf.sh 
30
31 if [ "$1" == "" ]; then
32     AAF_COMPONENTS=$(cat components)
33 else
34     AAF_COMPONENTS="$@"
35 fi
36
37 for AAF_COMPONENT in ${AAF_COMPONENTS}; do
38     LINKS=""
39     CMD_LINE=""
40     PUBLISH=""
41     case "$AAF_COMPONENT" in
42     "service")
43         PUBLISH="--publish 8100:8100"
44         if [ -z "$CASSANDRA_DOCKER" ]; then
45           CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-service && exec bin/service"
46         else
47           CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-service aaf-cass && exec bin/service"
48           LINKS="--link $CASSANDRA_DOCKER"
49           echo $CASSANDRA_CLUSTER
50         fi
51         ;;
52     "locate")
53         PUBLISH="--publish 8095:8095"
54         LINKS="--link aaf-cass --link aaf-service"
55         CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-locate aaf-service && exec bin/locate"
56         ;;
57     "oauth")
58         PUBLISH="--publish 8140:8140"
59         LINKS="--link aaf-cass --link aaf-service --link aaf-locate"
60         CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-oauth aaf-service && exec bin/oauth"
61         ;;
62     "cm")
63         PUBLISH="--publish 8150:8150"
64         LINKS="--link aaf-cass --link aaf-service --link aaf-locate --link aaf-oauth"
65         CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-cm aaf-locate && exec bin/cm"
66         ;;
67     "gui")
68         PUBLISH="--publish 8200:8200"
69         LINKS="--link aaf-service --link aaf-locate --link aaf-oauth --link aaf-cm"
70         CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-gui aaf-locate && exec bin/gui"
71         ;;
72     "fs")
73         PUBLISH="--publish 80:8096"
74         LINKS="--link aaf-locate"
75         CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-fs aaf-locate && exec bin/fs"
76         ;;
77     "hello")
78         PUBLISH="--publish 8130:8130"
79         LINKS="--link aaf-service --link aaf-locate --link aaf-oauth --link aaf-cm"
80         CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-hello aaf-locate && exec bin/hello"
81         ;;
82     esac
83
84     echo Starting aaf-$AAF_COMPONENT...
85     if [ -n "${DUSER}" ]; then
86        THE_USER="--user $DUSER"
87     fi
88
89
90     $DOCKER run  \
91         -d \
92         ${THE_USER} \
93         --name aaf-$AAF_COMPONENT \
94         ${LINKS} \
95         --env AAF_ENV=${AAF_ENV} \
96         --env aaf_locator_container=docker \
97         --env aaf_locator_container_ns=${NAMESPACE} \
98         --env aaf_locator_fqdn=${HOSTNAME} \
99         --env aaf_locator_public_fqdn=${HOSTNAME} \
100         --env aaf_deployed_version=${VERSION} \
101         --env LATITUDE=${LATITUDE} \
102         --env LONGITUDE=${LONGITUDE} \
103         --env CASSANDRA_CLUSTER=${CASSANDRA_CLUSTER} \
104         --env CASSANDRA_USER=${CASSANDRA_USER} \
105         --env CASSANDRA_PASSWORD=${CASSANDRA_PASSWORD} \
106         --env CASSANDRA_PORT=${CASSANDRA_PORT} \
107         $PUBLISH \
108         -v "aaf_config:$CONF_ROOT_DIR" \
109         -v "aaf_status:/opt/app/aaf/status" \
110         ${PREFIX}${ORG}/${PROJECT}/aaf_core:${VERSION} \
111         /bin/bash -c "$CMD_LINE"
112 done