More refinement, Agent.sh
[aaf/authz.git] / auth / docker / agent.sh
index 86fee5f..d319de4 100644 (file)
@@ -36,7 +36,7 @@ for V in VERSION DOCKER_REPOSITORY HOSTNAME AAF_FQDN AAF_FQDN_IP DEPLOY_FQI APP_
       case $V in
         DOCKER_REPOSITORY) 
                PROMPT="Docker Repo"
-               DEF=""
+               DEF="nexus3.onap.org:10003"
                ;;
         HOSTNAME) 
                PROMPT="HOSTNAME (blank for Default)"
@@ -47,11 +47,22 @@ for V in VERSION DOCKER_REPOSITORY HOSTNAME AAF_FQDN AAF_FQDN_IP DEPLOY_FQI APP_
          AAF_FQDN_IP)
                # Need AAF_FQDN's IP, because not might not be available in mini-container
                PROMPT="AAF FQDN IP"
-               DEF=$(host $AAF_FQDN | grep "has address" | tail -1 | cut -f 4 -d ' ')
+               LOOKUP=$(host "${AAF_FQDN}" | grep "has address")
+               if [ -n "${LOOKUP}" ]; then
+                   DEF=$(echo ${LOOKUP} | tail -1 | cut -f 4 -d ' ')
+                fi
                 ;;
-         APP_FQI)    PROMPT="App's FQI";; 
-         APP_FQDN)   PROMPT="App's Root FQDN";; 
-         VOLUME)     PROMPT="APP's AAF Configuration Volume";;
+         APP_FQDN)   PROMPT="App's Root FQDN";;
+         APP_FQI)    PROMPT="App's FQI"
+                    if [[ "${APP_FQDN}" != *"."* ]]; then
+                      DEF="${APP_FQDN}@${APP_FQDN}.onap.org"
+                     fi
+                    ;; 
+         VOLUME)     PROMPT="APP's AAF Configuration Volume"
+                    if [[ "${APP_FQDN}" != *"."* ]]; then
+                      DEF="${APP_FQDN}_config"
+                    fi
+                ;;
          DRIVER)     PROMPT=$V;DEF=local;;
         VERSION)    PROMPT="CADI Version";DEF=$CADI_VERSION;;
          LATITUDE|LONGITUDE) PROMPT="$V of Node";;
@@ -74,6 +85,7 @@ for V in VERSION DOCKER_REPOSITORY HOSTNAME AAF_FQDN AAF_FQDN_IP DEPLOY_FQI APP_
          fi
       fi
       echo "$V=$VAR" >> ./aaf.props
+      declare "$V"="$VAR"
    fi
 done
 . ./aaf.props
@@ -90,9 +102,12 @@ else
   PREFIX=""
 fi 
 
-$DOCKER run \
-    -it \
-    --rm \
+function run_it() {
+  if [ -n "${DUSER}" ]; then
+    USER_LINE="--user ${DUSER}"
+  fi
+  $DOCKER run  -it  --rm \
+    ${USER_LINE} \
     -v "${VOLUME}:/opt/app/osaaf" \
     --add-host="$AAF_FQDN:$AAF_FQDN_IP" \
     --env AAF_FQDN=${AAF_FQDN} \
@@ -102,6 +117,22 @@ $DOCKER run \
     --env APP_FQDN=${APP_FQDN} \
     --env LATITUDE=${LATITUDE} \
     --env LONGITUDE=${LONGITUDE} \
-    --name aaf_agent_$USER \
+    --name aaf-agent-$USER \
     "$PREFIX"onap/aaf/aaf_agent:$VERSION \
-    /bin/bash "$@"
+    bash -c "bash /opt/app/aaf_config/bin/agent.sh $PARAMS"
+}
+
+PARAMS=$@
+case "$1" in 
+  bash)
+    PARAMS="&& cd /opt/app/osaaf/local && exec bash"
+    run_it -it --rm  
+    ;;
+  taillog)
+    run_it -it --rm 
+    ;;
+  *)
+    run_it --rm 
+    ;;
+esac
+