blob: d643b5ed57651b88b87fd3752e8e2f1c2a09a443 [file] [log] [blame]
Sai Gandham67a6d892018-10-10 04:31:59 -05001#!/bin/bash
2
3
4# Fill out "aaf.props" if not filled out already
5if [ ! -e aaf.props ]; then
6 > ./aaf.props
7fi
8
9. ./aaf.props
10
11DOCKER=${DOCKER:=docker}
Instrumentala9391132018-10-16 12:34:12 -050012CADI_VERSION=${CADI_VERSION:=2.1.5-SNAPSHOT}
Sai Gandham67a6d892018-10-10 04:31:59 -050013
14for V in VERSION DOCKER_REPOSITORY AAF_FQDN AAF_FQDN_IP DEPLOY_FQI APP_FQDN APP_FQI VOLUME DRIVER LATITUDE LONGITUDE; do
15 if [ "$(grep $V ./aaf.props)" = "" ]; then
16 unset DEF
17 case $V in
18 DOCKER_REPOSITORY)
19 PROMPT="Docker Repo"
20 DEF=""
21 ;;
22 AAF_FQDN) PROMPT="AAF's FQDN";;
23 DEPLOY_FQI) PROMPT="Deployer's FQI";;
24 AAF_FQDN_IP)
25 # Need AAF_FQDN's IP, because not might not be available in mini-container
26 PROMPT="AAF FQDN IP"
27 DEF=$(host $AAF_FQDN | grep "has address" | tail -1 | cut -f 4 -d ' ')
28 ;;
29 APP_FQI) PROMPT="App's FQI";;
30 APP_FQDN) PROMPT="App's Root FQDN";;
31 VOLUME) PROMPT="APP's AAF Configuration Volume";;
32 DRIVER) PROMPT=$V;DEF=local;;
33 VERSION) PROMPT="CADI Version";DEF=$CADI_VERSION;;
34 LATITUDE|LONGITUDE) PROMPT="$V of Node";;
35 *) PROMPT=$V;;
36 esac
37 if [ "$DEF" = "" ]; then
38 PROMPT="$PROMPT: "
39 else
40 PROMPT="$PROMPT ($DEF): "
41 fi
42 read -p "$PROMPT" VAR
43 if [ "$VAR" = "" ]; then
44 if [ "$DEF" = "" ]; then
45 echo "agent.sh needs each value queried. Please start again."
46 exit
47 else
48 VAR=$DEF
49 fi
50 fi
51 echo "$V=$VAR" >> ./aaf.props
52 fi
53done
54. ./aaf.props
55
56# Make sure Container Volume exists
57if [ "$($DOCKER volume ls | grep ${VOLUME})" = "" ]; then
58 echo -n "Creating Volume: "
59 $DOCKER volume create -d ${DRIVER} ${VOLUME}
60fi
61
62if [ -n "$DOCKER_REPOSITORY" ]; then
63 PREFIX="$DOCKER_REPOSITORY/"
64else
65 PREFIX=""
66fi
67
68$DOCKER run \
69 -it \
70 --rm \
71 -v "${VOLUME}:/opt/app/osaaf" \
72 --add-host="$AAF_FQDN:$AAF_FQDN_IP" \
73 --env AAF_FQDN=${AAF_FQDN} \
74 --env DEPLOY_FQI=${DEPLOY_FQI} \
75 --env DEPLOY_PASSWORD=${DEPLOY_PASSWORD} \
76 --env APP_FQI=${APP_FQI} \
77 --env APP_FQDN=${APP_FQDN} \
78 --env LATITUDE=${LATITUDE} \
79 --env LONGITUDE=${LONGITUDE} \
80 --name aaf_agent_$USER \
81 "$PREFIX"onap/aaf/aaf_agent:$VERSION \
82 /bin/bash "$@"