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