Sai Gandham | 67a6d89 | 2018-10-10 04:31:59 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | |
| 4 | # Fill out "aaf.props" if not filled out already |
| 5 | if [ ! -e aaf.props ]; then |
| 6 | > ./aaf.props |
| 7 | fi |
| 8 | |
| 9 | . ./aaf.props |
| 10 | |
| 11 | DOCKER=${DOCKER:=docker} |
Instrumental | 7e5ccdd | 2018-10-12 12:55:37 -0500 | [diff] [blame] | 12 | CADI_VERSION=${CADI_VERSION:=2.1.4-SNAPSHOT} |
Sai Gandham | 67a6d89 | 2018-10-10 04:31:59 -0500 | [diff] [blame] | 13 | |
| 14 | for V in VERSION DOCKER_REPOSITORY AAF_FQDN AAF_FQDN_IP DEPLOY_FQI APP_FQDN APP_FQI VOLUME DRIVER LATITUDE LONGITUDE; do |
| 15 | if [ "$(grep $V ./aaf.props)" = "" ]; then |
| 16 | unset DEF |
| 17 | case $V in |
| 18 | DOCKER_REPOSITORY) |
| 19 | PROMPT="Docker Repo" |
| 20 | DEF="" |
| 21 | ;; |
| 22 | AAF_FQDN) PROMPT="AAF's FQDN";; |
| 23 | DEPLOY_FQI) PROMPT="Deployer's FQI";; |
| 24 | 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 | ;; |
| 29 | 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 |
| 53 | done |
| 54 | . ./aaf.props |
| 55 | |
| 56 | # Make sure Container Volume exists |
| 57 | if [ "$($DOCKER volume ls | grep ${VOLUME})" = "" ]; then |
| 58 | echo -n "Creating Volume: " |
| 59 | $DOCKER volume create -d ${DRIVER} ${VOLUME} |
| 60 | fi |
| 61 | |
| 62 | if [ -n "$DOCKER_REPOSITORY" ]; then |
| 63 | PREFIX="$DOCKER_REPOSITORY/" |
| 64 | else |
| 65 | PREFIX="" |
| 66 | fi |
| 67 | |
| 68 | $DOCKER run \ |
| 69 | -it \ |
| 70 | --rm \ |
| 71 | -v "${VOLUME}:/opt/app/osaaf" \ |
| 72 | --add-host="$AAF_FQDN:$AAF_FQDN_IP" \ |
| 73 | --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} \ |
| 78 | --env LATITUDE=${LATITUDE} \ |
| 79 | --env LONGITUDE=${LONGITUDE} \ |
| 80 | --name aaf_agent_$USER \ |
| 81 | "$PREFIX"onap/aaf/aaf_agent:$VERSION \ |
| 82 | /bin/bash "$@" |