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 | |
| 3 | CADI_VERSION=2.1.2-SNAPSHOT |
| 4 | |
| 5 | # Fill out "aaf.props" if not filled out already |
| 6 | if [ ! -e aaf.props ]; then |
| 7 | > ./aaf.props |
| 8 | fi |
Instrumental | 5b37375 | 2018-07-23 10:49:55 -0500 | [diff] [blame] | 9 | |
| 10 | . ./aaf.props |
| 11 | |
Instrumental | ca32331 | 2018-08-15 04:57:04 -0500 | [diff] [blame] | 12 | |
| 13 | 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] | 14 | if [ "$(grep $V ./aaf.props)" = "" ]; then |
| 15 | unset DEF |
| 16 | case $V in |
Instrumental | ca32331 | 2018-08-15 04:57:04 -0500 | [diff] [blame] | 17 | DOCKER_REPOSITORY) |
| 18 | PROMPT="Docker Repo" |
| 19 | DEF=nexus3.onap.org:10003 |
| 20 | ;; |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 21 | AAF_FQDN) PROMPT="AAF's FQDN";; |
| 22 | DEPLOY_FQI) PROMPT="Deployer's FQI";; |
Instrumental | 5b37375 | 2018-07-23 10:49:55 -0500 | [diff] [blame] | 23 | AAF_FQDN_IP) |
| 24 | # Need AAF_FQDN's IP, because not might not be available in mini-container |
| 25 | PROMPT="AAF FQDN IP" |
| 26 | DEF=$(host $AAF_FQDN | grep "has address" | tail -1 | cut -f 4 -d ' ') |
| 27 | ;; |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 28 | APP_FQI) PROMPT="App's FQI";; |
| 29 | APP_FQDN) PROMPT="App's Root FQDN";; |
| 30 | VOLUME) PROMPT="APP's AAF Configuration Volume";; |
| 31 | DRIVER) PROMPT=$V;DEF=local;; |
| 32 | VERSION) PROMPT="CADI Version";DEF=$CADI_VERSION;; |
| 33 | LATITUDE|LONGITUDE) PROMPT="$V of Node";; |
| 34 | *) PROMPT=$V;; |
| 35 | esac |
| 36 | if [ "$DEF" = "" ]; then |
| 37 | PROMPT="$PROMPT: " |
| 38 | else |
| 39 | PROMPT="$PROMPT ($DEF): " |
| 40 | fi |
| 41 | read -p "$PROMPT" VAR |
| 42 | if [ "$VAR" = "" ]; then |
| 43 | if [ "$DEF" = "" ]; then |
| 44 | echo "agent.sh needs each value queried. Please start again." |
| 45 | exit |
| 46 | else |
| 47 | VAR=$DEF |
| 48 | fi |
| 49 | fi |
| 50 | echo "$V=$VAR" >> ./aaf.props |
| 51 | fi |
| 52 | done |
| 53 | . ./aaf.props |
| 54 | |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 55 | # Make sure Container Volume exists |
| 56 | if [ "$(docker volume ls | grep ${VOLUME})" = "" ]; then |
| 57 | echo -n "Creating Volume: " |
| 58 | docker volume create -d ${DRIVER} ${VOLUME} |
| 59 | fi |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 60 | |
Instrumental | 9ec2895 | 2018-07-12 11:14:10 -0500 | [diff] [blame] | 61 | docker run \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 62 | -it \ |
| 63 | --rm \ |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 64 | --mount 'type=volume,src='${VOLUME}',dst=/opt/app/osaaf,volume-driver='${DRIVER} \ |
Instrumental | c23f2cd | 2018-07-20 20:27:49 -0500 | [diff] [blame] | 65 | --add-host="$AAF_FQDN:$AAF_FQDN_IP" \ |
Instrumental | 32cdd55 | 2018-07-19 13:29:32 -0500 | [diff] [blame] | 66 | --env AAF_FQDN=${AAF_FQDN} \ |
| 67 | --env DEPLOY_FQI=${DEPLOY_FQI} \ |
| 68 | --env DEPLOY_PASSWORD=${DEPLOY_PASSWORD} \ |
| 69 | --env APP_FQI=${APP_FQI} \ |
| 70 | --env APP_FQDN=${APP_FQDN} \ |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 71 | --env LATITUDE=${LATITUDE} \ |
| 72 | --env LONGITUDE=${LONGITUDE} \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 73 | --name aaf_agent_$USER \ |
Instrumental | ca32331 | 2018-08-15 04:57:04 -0500 | [diff] [blame] | 74 | $DOCKER_REPOSITORY/onap/aaf/aaf_agent:$VERSION \ |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 75 | /bin/bash "$@" |