blob: 38b1070d8148681ec0e6ae18bf0fb521aef9fb32 [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"
Instrumental365638c2018-10-01 15:26:03 -050019 DEF=""
Instrumentalca323312018-08-15 04:57:04 -050020 ;;
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
Instrumental365638c2018-10-01 15:26:03 -050061if [ -n "$DOCKER_REPOSITORY" ]; then
62 PREFIX="$DOCKER_REPOSITORY/"
63else
64 PREFIX=""
65fi
66
Instrumental9ec28952018-07-12 11:14:10 -050067docker run \
Instrumental4ad47632018-07-13 15:49:26 -050068 -it \
69 --rm \
Instrumental32cdd552018-07-19 13:29:32 -050070 --mount 'type=volume,src='${VOLUME}',dst=/opt/app/osaaf,volume-driver='${DRIVER} \
Instrumentalc23f2cd2018-07-20 20:27:49 -050071 --add-host="$AAF_FQDN:$AAF_FQDN_IP" \
Instrumental32cdd552018-07-19 13:29:32 -050072 --env AAF_FQDN=${AAF_FQDN} \
73 --env DEPLOY_FQI=${DEPLOY_FQI} \
74 --env DEPLOY_PASSWORD=${DEPLOY_PASSWORD} \
75 --env APP_FQI=${APP_FQI} \
76 --env APP_FQDN=${APP_FQDN} \
Instrumental9c8a8b02018-07-16 18:41:10 -050077 --env LATITUDE=${LATITUDE} \
78 --env LONGITUDE=${LONGITUDE} \
Instrumental4ad47632018-07-13 15:49:26 -050079 --name aaf_agent_$USER \
Instrumental365638c2018-10-01 15:26:03 -050080 "$PREFIX"onap/aaf/aaf_agent:$VERSION \
Instrumental4ad47632018-07-13 15:49:26 -050081 /bin/bash "$@"