Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Instrumental | 7a1817b | 2018-11-05 11:11:15 -0600 | [diff] [blame] | 2 | ######### |
| 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 | # |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 21 | |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 22 | |
| 23 | # Fill out "aaf.props" if not filled out already |
| 24 | if [ ! -e aaf.props ]; then |
| 25 | > ./aaf.props |
| 26 | fi |
Instrumental | 5b37375 | 2018-07-23 10:49:55 -0500 | [diff] [blame] | 27 | |
| 28 | . ./aaf.props |
| 29 | |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 30 | DOCKER=${DOCKER:=docker} |
Instrumental | 2c79dd1 | 2018-11-09 07:56:25 -0600 | [diff] [blame^] | 31 | CADI_VERSION=${CADI_VERSION:=2.1.8-SNAPSHOT} |
Instrumental | ca32331 | 2018-08-15 04:57:04 -0500 | [diff] [blame] | 32 | |
| 33 | for V in VERSION DOCKER_REPOSITORY AAF_FQDN AAF_FQDN_IP DEPLOY_FQI APP_FQDN APP_FQI VOLUME DRIVER LATITUDE LONGITUDE; do |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 34 | if [ "$(grep $V ./aaf.props)" = "" ]; then |
| 35 | unset DEF |
| 36 | case $V in |
Instrumental | ca32331 | 2018-08-15 04:57:04 -0500 | [diff] [blame] | 37 | DOCKER_REPOSITORY) |
| 38 | PROMPT="Docker Repo" |
Instrumental | 365638c | 2018-10-01 15:26:03 -0500 | [diff] [blame] | 39 | DEF="" |
Instrumental | ca32331 | 2018-08-15 04:57:04 -0500 | [diff] [blame] | 40 | ;; |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 41 | AAF_FQDN) PROMPT="AAF's FQDN";; |
| 42 | DEPLOY_FQI) PROMPT="Deployer's FQI";; |
Instrumental | 5b37375 | 2018-07-23 10:49:55 -0500 | [diff] [blame] | 43 | AAF_FQDN_IP) |
| 44 | # Need AAF_FQDN's IP, because not might not be available in mini-container |
| 45 | PROMPT="AAF FQDN IP" |
| 46 | DEF=$(host $AAF_FQDN | grep "has address" | tail -1 | cut -f 4 -d ' ') |
| 47 | ;; |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 48 | APP_FQI) PROMPT="App's FQI";; |
| 49 | APP_FQDN) PROMPT="App's Root FQDN";; |
| 50 | VOLUME) PROMPT="APP's AAF Configuration Volume";; |
| 51 | DRIVER) PROMPT=$V;DEF=local;; |
| 52 | VERSION) PROMPT="CADI Version";DEF=$CADI_VERSION;; |
| 53 | LATITUDE|LONGITUDE) PROMPT="$V of Node";; |
| 54 | *) PROMPT=$V;; |
| 55 | esac |
| 56 | if [ "$DEF" = "" ]; then |
| 57 | PROMPT="$PROMPT: " |
| 58 | else |
| 59 | PROMPT="$PROMPT ($DEF): " |
| 60 | fi |
| 61 | read -p "$PROMPT" VAR |
| 62 | if [ "$VAR" = "" ]; then |
| 63 | if [ "$DEF" = "" ]; then |
| 64 | echo "agent.sh needs each value queried. Please start again." |
| 65 | exit |
| 66 | else |
| 67 | VAR=$DEF |
| 68 | fi |
| 69 | fi |
| 70 | echo "$V=$VAR" >> ./aaf.props |
| 71 | fi |
| 72 | done |
| 73 | . ./aaf.props |
| 74 | |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 75 | # Make sure Container Volume exists |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 76 | if [ "$($DOCKER volume ls | grep ${VOLUME})" = "" ]; then |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 77 | echo -n "Creating Volume: " |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 78 | $DOCKER volume create -d ${DRIVER} ${VOLUME} |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 79 | fi |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 80 | |
Instrumental | 365638c | 2018-10-01 15:26:03 -0500 | [diff] [blame] | 81 | if [ -n "$DOCKER_REPOSITORY" ]; then |
| 82 | PREFIX="$DOCKER_REPOSITORY/" |
| 83 | else |
| 84 | PREFIX="" |
| 85 | fi |
| 86 | |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 87 | $DOCKER run \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 88 | -it \ |
| 89 | --rm \ |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 90 | -v "${VOLUME}:/opt/app/osaaf" \ |
Instrumental | c23f2cd | 2018-07-20 20:27:49 -0500 | [diff] [blame] | 91 | --add-host="$AAF_FQDN:$AAF_FQDN_IP" \ |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 92 | --env AAF_FQDN=${AAF_FQDN} \ |
| 93 | --env DEPLOY_FQI=${DEPLOY_FQI} \ |
| 94 | --env DEPLOY_PASSWORD=${DEPLOY_PASSWORD} \ |
| 95 | --env APP_FQI=${APP_FQI} \ |
| 96 | --env APP_FQDN=${APP_FQDN} \ |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 97 | --env LATITUDE=${LATITUDE} \ |
| 98 | --env LONGITUDE=${LONGITUDE} \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 99 | --name aaf_agent_$USER \ |
Instrumental | 365638c | 2018-10-01 15:26:03 -0500 | [diff] [blame] | 100 | "$PREFIX"onap/aaf/aaf_agent:$VERSION \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 101 | /bin/bash "$@" |