summaryrefslogtreecommitdiffstats
path: root/auth/docker/drun.sh
blob: cdd8b3c48d89f642b7bde18614e90da3b7f9a4b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
#########
#  ============LICENSE_START====================================================
#  org.onap.aaf
#  ===========================================================================
#  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
#  ===========================================================================
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#  ============LICENSE_END====================================================
#
# Pull in Variables from d.props
. ./d.props

CASSANDRA_CLUSTER=${CASSANDRA_CLUSTER:=$CASSANDRA_DOCKER}

DOCKER=${DOCKER:=docker}

# Running without params keeps from being TTY
bash ./aaf.sh 

if [ "$1" == "" ]; then
    AAF_COMPONENTS=$(cat components)
else
    AAF_COMPONENTS="$@"
fi

for AAF_COMPONENT in ${AAF_COMPONENTS}; do
    LINKS=""
    CMD_LINE=""
    PUBLISH=""
    case "$AAF_COMPONENT" in
    "service")
        PUBLISH="--publish 8100:8100"
        if [ -z "$CASSANDRA_DOCKER" ]; then
	  CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-service && exec bin/service"
        else
	  CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-service aaf-cass && exec bin/service"
          LINKS="--link $CASSANDRA_DOCKER"
	  echo $CASSANDRA_CLUSTER
        fi
        ;;
    "locate")
        PUBLISH="--publish 8095:8095"
        LINKS="--link aaf-cass --link aaf-service"
	CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-locate aaf-service && exec bin/locate"
        ;;
    "oauth")
        PUBLISH="--publish 8140:8140"
        LINKS="--link aaf-cass --link aaf-service --link aaf-locate"
	CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-oauth aaf-service && exec bin/oauth"
        ;;
    "cm")
        PUBLISH="--publish 8150:8150"
        LINKS="--link aaf-cass --link aaf-service --link aaf-locate"
	CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-cm aaf-locate && exec bin/cm"
        ;;
    "gui")
        PUBLISH="--publish 8200:8200"
        LINKS="--link aaf-service --link aaf-locate --link aaf-oauth --link aaf-cm"
	CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-gui aaf-locate && exec bin/gui"
        ;;
    "fs")
        PUBLISH="--publish 80:8096"
        LINKS=""
	CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-fs aaf-locate && exec bin/fs"
        ;;
    "hello")
        PUBLISH="--publish 8130:8130"
        LINKS="--link aaf-service --link aaf-locate --link aaf-oauth --link aaf-cm"
	CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-hello aaf-locate && exec bin/hello"
        ;;
    esac

    echo Starting aaf-$AAF_COMPONENT...

    #for A in aaf.osaaf.org $AH_ROOT; do 
       #ADD_HOST="$ADD_HOST --add-host=$A:$HOST_IP"
    #done

    #if [ ! -z "$LINKS" ] && [[ "$CASS_HOST" =~ ":" ]]; then
       #ADD_HOST="$ADD_HOST --add-host=$CASS_HOST"
    #fi
    #--hostname="${AAF_COMPONENT}.${NAMESPACE}" \
    #	$ADD_HOST \
    $DOCKER run  \
        -d \
        --name aaf-$AAF_COMPONENT \
        ${LINKS} \
        --env AAF_ENV=${AAF_ENV} \
        --env aaf_locator_container=docker \
        --env aaf_locator_fqdn=$HOSTNAME \
        --env LATITUDE=${LATITUDE} \
        --env LONGITUDE=${LONGITUDE} \
        --env CASSANDRA_CLUSTER=${CASSANDRA_CLUSTER} \
        --env CASSANDRA_USER=${CASSANDRA_USER} \
        --env CASSANDRA_PASSWORD=${CASSANDRA_PASSWORD} \
        --env CASSANDRA_PORT=${CASSANDRA_PORT} \
        $PUBLISH \
        -v "aaf_config:$CONF_ROOT_DIR" \
        -v "aaf_status:/opt/app/aaf/status" \
        ${PREFIX}${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} \
	/bin/bash -c "$CMD_LINE"
done