blob: af04cf298d37c1571587d285e753930ad605fb00 [file] [log] [blame]
Instrumental9ec28952018-07-12 11:14:10 -05001#!/bin/bash
Instrumental32cdd552018-07-19 13:29:32 -05002
Instrumental32cdd552018-07-19 13:29:32 -05003
4# Fill out "aaf.props" if not filled out already
5if [ ! -e aaf.props ]; then
6 > ./aaf.props
7fi
Instrumental5b373752018-07-23 10:49:55 -05008
9. ./aaf.props
10
Instrumental94053612018-10-08 11:27:18 -050011DOCKER=${DOCKER:=docker}
12CADI_VERSION=${CADI_VERSION:=2.1.2-SNAPSHOT}
Instrumentalca323312018-08-15 04:57:04 -050013
14for 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 -050015 if [ "$(grep $V ./aaf.props)" = "" ]; then
16 unset DEF
17 case $V in
Instrumentalca323312018-08-15 04:57:04 -050018 DOCKER_REPOSITORY)
19 PROMPT="Docker Repo"
Instrumental365638c2018-10-01 15:26:03 -050020 DEF=""
Instrumentalca323312018-08-15 04:57:04 -050021 ;;
Instrumental32cdd552018-07-19 13:29:32 -050022 AAF_FQDN) PROMPT="AAF's FQDN";;
23 DEPLOY_FQI) PROMPT="Deployer's FQI";;
Instrumental5b373752018-07-23 10:49:55 -050024 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 ;;
Instrumental32cdd552018-07-19 13:29:32 -050029 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
Instrumental32cdd552018-07-19 13:29:32 -050056# Make sure Container Volume exists
Instrumental94053612018-10-08 11:27:18 -050057if [ "$($DOCKER volume ls | grep ${VOLUME})" = "" ]; then
Instrumental32cdd552018-07-19 13:29:32 -050058 echo -n "Creating Volume: "
Instrumental94053612018-10-08 11:27:18 -050059 $DOCKER volume create -d ${DRIVER} ${VOLUME}
Instrumental32cdd552018-07-19 13:29:32 -050060fi
Instrumental4ad47632018-07-13 15:49:26 -050061
Instrumental365638c2018-10-01 15:26:03 -050062if [ -n "$DOCKER_REPOSITORY" ]; then
63 PREFIX="$DOCKER_REPOSITORY/"
64else
65 PREFIX=""
66fi
67
Instrumental94053612018-10-08 11:27:18 -050068$DOCKER run \
Instrumental4ad47632018-07-13 15:49:26 -050069 -it \
70 --rm \
Instrumental94053612018-10-08 11:27:18 -050071 -v "${VOLUME}:/opt/app/osaaf" \
Instrumentalc23f2cd2018-07-20 20:27:49 -050072 --add-host="$AAF_FQDN:$AAF_FQDN_IP" \
Instrumental32cdd552018-07-19 13:29:32 -050073 --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} \
Instrumental9c8a8b02018-07-16 18:41:10 -050078 --env LATITUDE=${LATITUDE} \
79 --env LONGITUDE=${LONGITUDE} \
Instrumental4ad47632018-07-13 15:49:26 -050080 --name aaf_agent_$USER \
Instrumental365638c2018-10-01 15:26:03 -050081 "$PREFIX"onap/aaf/aaf_agent:$VERSION \
Instrumental4ad47632018-07-13 15:49:26 -050082 /bin/bash "$@"