blob: 86fee5f6f08828b41ff74e1da36818cd2fceb535 [file] [log] [blame]
Instrumental9ec28952018-07-12 11:14:10 -05001#!/bin/bash
Instrumental7a1817b2018-11-05 11:11:15 -06002#########
3# ============LICENSE_START====================================================
4# org.onap.aaf
5# ===========================================================================
6# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
7# ===========================================================================
8# Licensed under the Apache License, Version 2.0 (the "License");
9# you may not use this file except in compliance with the License.
10# You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS,
16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17# See the License for the specific language governing permissions and
18# limitations under the License.
19# ============LICENSE_END====================================================
20#
Instrumental21872892018-12-12 17:16:30 -060021
22
Instrumental32cdd552018-07-19 13:29:32 -050023# Fill out "aaf.props" if not filled out already
24if [ ! -e aaf.props ]; then
25 > ./aaf.props
26fi
Instrumental5b373752018-07-23 10:49:55 -050027
28. ./aaf.props
29
Instrumental21872892018-12-12 17:16:30 -060030DOCKER=${DOCKER:=docker}
Instrumental12414fe2019-01-22 10:27:32 -060031CADI_VERSION=${CADI_VERSION:=2.1.10-SNAPSHOT}
Instrumentalca323312018-08-15 04:57:04 -050032
Instrumental12414fe2019-01-22 10:27:32 -060033for V in VERSION DOCKER_REPOSITORY HOSTNAME AAF_FQDN AAF_FQDN_IP DEPLOY_FQI APP_FQDN APP_FQI VOLUME DRIVER LATITUDE LONGITUDE; do
Instrumental32cdd552018-07-19 13:29:32 -050034 if [ "$(grep $V ./aaf.props)" = "" ]; then
35 unset DEF
36 case $V in
Instrumentalca323312018-08-15 04:57:04 -050037 DOCKER_REPOSITORY)
Instrumental21872892018-12-12 17:16:30 -060038 PROMPT="Docker Repo"
39 DEF=""
40 ;;
Instrumental12414fe2019-01-22 10:27:32 -060041 HOSTNAME)
42 PROMPT="HOSTNAME (blank for Default)"
43 DEF=""
44 ;;
Instrumental21872892018-12-12 17:16:30 -060045 AAF_FQDN) PROMPT="AAF's FQDN";;
46 DEPLOY_FQI) PROMPT="Deployer's FQI";;
Instrumental5b373752018-07-23 10:49:55 -050047 AAF_FQDN_IP)
Instrumental21872892018-12-12 17:16:30 -060048 # Need AAF_FQDN's IP, because not might not be available in mini-container
49 PROMPT="AAF FQDN IP"
50 DEF=$(host $AAF_FQDN | grep "has address" | tail -1 | cut -f 4 -d ' ')
51 ;;
Instrumental32cdd552018-07-19 13:29:32 -050052 APP_FQI) PROMPT="App's FQI";;
53 APP_FQDN) PROMPT="App's Root FQDN";;
Instrumental21872892018-12-12 17:16:30 -060054 VOLUME) PROMPT="APP's AAF Configuration Volume";;
Instrumental32cdd552018-07-19 13:29:32 -050055 DRIVER) PROMPT=$V;DEF=local;;
Instrumental21872892018-12-12 17:16:30 -060056 VERSION) PROMPT="CADI Version";DEF=$CADI_VERSION;;
Instrumental32cdd552018-07-19 13:29:32 -050057 LATITUDE|LONGITUDE) PROMPT="$V of Node";;
58 *) PROMPT=$V;;
59 esac
60 if [ "$DEF" = "" ]; then
61 PROMPT="$PROMPT: "
62 else
63 PROMPT="$PROMPT ($DEF): "
64 fi
65 read -p "$PROMPT" VAR
66 if [ "$VAR" = "" ]; then
67 if [ "$DEF" = "" ]; then
Instrumental12414fe2019-01-22 10:27:32 -060068 if [ "$V" != "HOSTNAME" ]; then
69 echo "agent.sh needs each value queried. Please start again."
70 exit
71 fi
Instrumental32cdd552018-07-19 13:29:32 -050072 else
73 VAR=$DEF
74 fi
75 fi
76 echo "$V=$VAR" >> ./aaf.props
77 fi
78done
79. ./aaf.props
80
Instrumental21872892018-12-12 17:16:30 -060081# Make sure Container Volume exists
82if [ "$($DOCKER volume ls | grep ${VOLUME})" = "" ]; then
83 echo -n "Creating Volume: "
84 $DOCKER volume create -d ${DRIVER} ${VOLUME}
85fi
86
Instrumental365638c2018-10-01 15:26:03 -050087if [ -n "$DOCKER_REPOSITORY" ]; then
88 PREFIX="$DOCKER_REPOSITORY/"
89else
90 PREFIX=""
91fi
92
Instrumental21872892018-12-12 17:16:30 -060093$DOCKER run \
Instrumental4ad47632018-07-13 15:49:26 -050094 -it \
95 --rm \
Instrumental94053612018-10-08 11:27:18 -050096 -v "${VOLUME}:/opt/app/osaaf" \
Instrumentalc23f2cd2018-07-20 20:27:49 -050097 --add-host="$AAF_FQDN:$AAF_FQDN_IP" \
Instrumental32cdd552018-07-19 13:29:32 -050098 --env AAF_FQDN=${AAF_FQDN} \
99 --env DEPLOY_FQI=${DEPLOY_FQI} \
100 --env DEPLOY_PASSWORD=${DEPLOY_PASSWORD} \
101 --env APP_FQI=${APP_FQI} \
102 --env APP_FQDN=${APP_FQDN} \
Instrumental9c8a8b02018-07-16 18:41:10 -0500103 --env LATITUDE=${LATITUDE} \
104 --env LONGITUDE=${LONGITUDE} \
Instrumental4ad47632018-07-13 15:49:26 -0500105 --name aaf_agent_$USER \
Instrumental365638c2018-10-01 15:26:03 -0500106 "$PREFIX"onap/aaf/aaf_agent:$VERSION \
Instrumental4ad47632018-07-13 15:49:26 -0500107 /bin/bash "$@"