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 | 2187289 | 2018-12-12 17:16:30 -0600 | [diff] [blame] | 21 | |
| 22 | |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 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 | 2187289 | 2018-12-12 17:16:30 -0600 | [diff] [blame] | 30 | DOCKER=${DOCKER:=docker} |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 31 | CADI_VERSION=${CADI_VERSION:=2.1.10-SNAPSHOT} |
Instrumental | ca32331 | 2018-08-15 04:57:04 -0500 | [diff] [blame] | 32 | |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 33 | for V in VERSION DOCKER_REPOSITORY HOSTNAME 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) |
Instrumental | 2187289 | 2018-12-12 17:16:30 -0600 | [diff] [blame] | 38 | PROMPT="Docker Repo" |
| 39 | DEF="" |
| 40 | ;; |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 41 | HOSTNAME) |
| 42 | PROMPT="HOSTNAME (blank for Default)" |
| 43 | DEF="" |
| 44 | ;; |
Instrumental | 2187289 | 2018-12-12 17:16:30 -0600 | [diff] [blame] | 45 | AAF_FQDN) PROMPT="AAF's FQDN";; |
| 46 | DEPLOY_FQI) PROMPT="Deployer's FQI";; |
Instrumental | 5b37375 | 2018-07-23 10:49:55 -0500 | [diff] [blame] | 47 | AAF_FQDN_IP) |
Instrumental | 2187289 | 2018-12-12 17:16:30 -0600 | [diff] [blame] | 48 | # 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 | ;; |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 52 | APP_FQI) PROMPT="App's FQI";; |
| 53 | APP_FQDN) PROMPT="App's Root FQDN";; |
Instrumental | 2187289 | 2018-12-12 17:16:30 -0600 | [diff] [blame] | 54 | VOLUME) PROMPT="APP's AAF Configuration Volume";; |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 55 | DRIVER) PROMPT=$V;DEF=local;; |
Instrumental | 2187289 | 2018-12-12 17:16:30 -0600 | [diff] [blame] | 56 | VERSION) PROMPT="CADI Version";DEF=$CADI_VERSION;; |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 57 | 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 |
Instrumental | 12414fe | 2019-01-22 10:27:32 -0600 | [diff] [blame] | 68 | if [ "$V" != "HOSTNAME" ]; then |
| 69 | echo "agent.sh needs each value queried. Please start again." |
| 70 | exit |
| 71 | fi |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 72 | else |
| 73 | VAR=$DEF |
| 74 | fi |
| 75 | fi |
| 76 | echo "$V=$VAR" >> ./aaf.props |
| 77 | fi |
| 78 | done |
| 79 | . ./aaf.props |
| 80 | |
Instrumental | 2187289 | 2018-12-12 17:16:30 -0600 | [diff] [blame] | 81 | # Make sure Container Volume exists |
| 82 | if [ "$($DOCKER volume ls | grep ${VOLUME})" = "" ]; then |
| 83 | echo -n "Creating Volume: " |
| 84 | $DOCKER volume create -d ${DRIVER} ${VOLUME} |
| 85 | fi |
| 86 | |
Instrumental | 365638c | 2018-10-01 15:26:03 -0500 | [diff] [blame] | 87 | if [ -n "$DOCKER_REPOSITORY" ]; then |
| 88 | PREFIX="$DOCKER_REPOSITORY/" |
| 89 | else |
| 90 | PREFIX="" |
| 91 | fi |
| 92 | |
Instrumental | 2187289 | 2018-12-12 17:16:30 -0600 | [diff] [blame] | 93 | $DOCKER run \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 94 | -it \ |
| 95 | --rm \ |
Instrumental | 9405361 | 2018-10-08 11:27:18 -0500 | [diff] [blame] | 96 | -v "${VOLUME}:/opt/app/osaaf" \ |
Instrumental | c23f2cd | 2018-07-20 20:27:49 -0500 | [diff] [blame] | 97 | --add-host="$AAF_FQDN:$AAF_FQDN_IP" \ |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 98 | --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} \ |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 103 | --env LATITUDE=${LATITUDE} \ |
| 104 | --env LONGITUDE=${LONGITUDE} \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 105 | --name aaf_agent_$USER \ |
Instrumental | 365638c | 2018-10-01 15:26:03 -0500 | [diff] [blame] | 106 | "$PREFIX"onap/aaf/aaf_agent:$VERSION \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 107 | /bin/bash "$@" |