blob: 1ca12eb89548c855791f5a3f3dbf1128f447bde0 [file] [log] [blame]
Instrumental9ec28952018-07-12 11:14:10 -05001#!/bin/bash
Instrumental32cdd552018-07-19 13:29:32 -05002
3CADI_VERSION=2.1.2-SNAPSHOT
4
5# Fill out "aaf.props" if not filled out already
6if [ ! -e aaf.props ]; then
7 > ./aaf.props
8fi
Instrumental5b373752018-07-23 10:49:55 -05009
10. ./aaf.props
11
Instrumentalca323312018-08-15 04:57:04 -050012
13for V in VERSION DOCKER_REPOSITORY AAF_FQDN AAF_FQDN_IP DEPLOY_FQI APP_FQDN APP_FQI VOLUME DRIVER LATITUDE LONGITUDE; do
Instrumental32cdd552018-07-19 13:29:32 -050014 if [ "$(grep $V ./aaf.props)" = "" ]; then
15 unset DEF
16 case $V in
Instrumentalca323312018-08-15 04:57:04 -050017 DOCKER_REPOSITORY)
18 PROMPT="Docker Repo"
19 DEF=nexus3.onap.org:10003
20 ;;
Instrumental32cdd552018-07-19 13:29:32 -050021 AAF_FQDN) PROMPT="AAF's FQDN";;
22 DEPLOY_FQI) PROMPT="Deployer's FQI";;
Instrumental5b373752018-07-23 10:49:55 -050023 AAF_FQDN_IP)
24 # Need AAF_FQDN's IP, because not might not be available in mini-container
25 PROMPT="AAF FQDN IP"
26 DEF=$(host $AAF_FQDN | grep "has address" | tail -1 | cut -f 4 -d ' ')
27 ;;
Instrumental32cdd552018-07-19 13:29:32 -050028 APP_FQI) PROMPT="App's FQI";;
29 APP_FQDN) PROMPT="App's Root FQDN";;
30 VOLUME) PROMPT="APP's AAF Configuration Volume";;
31 DRIVER) PROMPT=$V;DEF=local;;
32 VERSION) PROMPT="CADI Version";DEF=$CADI_VERSION;;
33 LATITUDE|LONGITUDE) PROMPT="$V of Node";;
34 *) PROMPT=$V;;
35 esac
36 if [ "$DEF" = "" ]; then
37 PROMPT="$PROMPT: "
38 else
39 PROMPT="$PROMPT ($DEF): "
40 fi
41 read -p "$PROMPT" VAR
42 if [ "$VAR" = "" ]; then
43 if [ "$DEF" = "" ]; then
44 echo "agent.sh needs each value queried. Please start again."
45 exit
46 else
47 VAR=$DEF
48 fi
49 fi
50 echo "$V=$VAR" >> ./aaf.props
51 fi
52done
53. ./aaf.props
54
Instrumental32cdd552018-07-19 13:29:32 -050055# Make sure Container Volume exists
56if [ "$(docker volume ls | grep ${VOLUME})" = "" ]; then
57 echo -n "Creating Volume: "
58 docker volume create -d ${DRIVER} ${VOLUME}
59fi
Instrumental4ad47632018-07-13 15:49:26 -050060
Instrumental9ec28952018-07-12 11:14:10 -050061docker run \
Instrumental4ad47632018-07-13 15:49:26 -050062 -it \
63 --rm \
Instrumental32cdd552018-07-19 13:29:32 -050064 --mount 'type=volume,src='${VOLUME}',dst=/opt/app/osaaf,volume-driver='${DRIVER} \
Instrumentalc23f2cd2018-07-20 20:27:49 -050065 --add-host="$AAF_FQDN:$AAF_FQDN_IP" \
Instrumental32cdd552018-07-19 13:29:32 -050066 --env AAF_FQDN=${AAF_FQDN} \
67 --env DEPLOY_FQI=${DEPLOY_FQI} \
68 --env DEPLOY_PASSWORD=${DEPLOY_PASSWORD} \
69 --env APP_FQI=${APP_FQI} \
70 --env APP_FQDN=${APP_FQDN} \
Instrumental9c8a8b02018-07-16 18:41:10 -050071 --env LATITUDE=${LATITUDE} \
72 --env LONGITUDE=${LONGITUDE} \
Instrumental4ad47632018-07-13 15:49:26 -050073 --name aaf_agent_$USER \
Instrumentalca323312018-08-15 04:57:04 -050074 $DOCKER_REPOSITORY/onap/aaf/aaf_agent:$VERSION \
Instrumental4ad47632018-07-13 15:49:26 -050075 /bin/bash "$@"