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