Merge "Attrib.java: Fixed sonar issue"
[aaf/authz.git] / auth / docker / drun.sh
1 #!/bin/bash
2 # Pull in Variables from d.props
3 . ./d.props
4
5 # Only need Cassandra Link Info when initializing the container.
6 if [ ! -e ./cass.props ]; then
7     cp cass.props.init cass.props
8 fi
9
10 CASS_IS_SET="$(grep '<Cass IP>' cass.props)"
11 if [ -n "$CASS_IS_SET" ]; then
12     CASS_IP="$(docker container inspect aaf_cass | grep \"IPAddress\": -m 1 | cut -d '"' -f 4)"
13     if [ -n "$CASS_IP" ]; then
14       sed -i -e "s/\(^.*:\).*/\1$CASS_IP/" cass.props
15     else
16       echo "Set CASSASNDRA IP in cass.props"
17       exit
18     fi
19 fi
20
21 . ./cass.props
22
23 if [ "$1" == "" ]; then
24     AAF_COMPONENTS=$(cat components)
25 else
26     AAF_COMPONENTS="$@"
27 fi
28
29 for AAF_COMPONENT in ${AAF_COMPONENTS}; do
30     case "$AAF_COMPONENT" in
31     "service")
32         PORTMAP="8100:8100"
33         LINKS="--link aaf_cass:cassandra --add-host=$CASS_HOST"
34         ;;
35     "locate")
36         PORTMAP="8095:8095"
37         LINKS="--link aaf_cass:cassandra --add-host=$CASS_HOST"
38         ;;
39     "oauth")
40         PORTMAP="8140:8140"
41         LINKS="--link aaf_cass:cassandra --add-host=$CASS_HOST"
42         ;;
43     "gui")
44         PORTMAP="8200:8200"
45         ;;
46     "cm")
47         PORTMAP="8150:8150"
48         LINKS="--link aaf_cass:cassandra --add-host=$CASS_HOST"
49         ;;
50     "hello")
51         PORTMAP="8130:8130"
52         ;;
53     "fs")
54         PORTMAP="80:8096"
55         ;;
56     esac
57
58     echo Starting aaf_$AAF_COMPONENT...
59
60     docker run \
61         -d \
62         --name aaf_$AAF_COMPONENT \
63         --hostname="${AAF_COMPONENT}.aaf.osaaf.org" \
64         --add-host="$HOSTNAME:$HOST_IP" \
65         --add-host="aaf.osaaf.org:$HOST_IP" \
66         ${LINKS} \
67         --publish $PORTMAP \
68         --mount 'type=volume,src=aaf_config,dst='$CONF_ROOT_DIR',volume-driver=local' \
69         ${PREFIX}${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION}
70 done