changeset 132:a095257a342b

DEP-12: add auto-config of initial integration keys
author smith@nwoca.org
date Mon, 08 May 2017 22:13:40 +0100
parents 70ec01165f8e
children 1e37ed533797
files compose2/preview/setup.sh compose2/preview/usxs-services.yml
diffstat 2 files changed, 41 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/compose2/preview/setup.sh	Mon May 08 14:43:56 2017 -0400
+++ b/compose2/preview/setup.sh	Mon May 08 22:13:40 2017 +0100
@@ -11,23 +11,48 @@
 source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/.functions.sh"
 
 base=$(dirname "${BASH_SOURCE[0]}")
+default_name=$(basename $PWD)
 
 echo "Preparing '$(basename $PWD)' with default USxS configuration" 
 
-if [ ! -e "docker-compose.yml" ] ; then
-    cp $base/usxs-template.yml ./docker-compose.yml
-    echo "created docker-compose.yml"
-fi
-
 touch .env
-
 source .env
 
 if [ "$COMPOSE_PROJECT_NAME" == "" ]
 then
-   echo "COMPOSE_PROJECT_NAME=$(basename $PWD)" >> .env
+   read -e -p "Enter project name: <${default_name}> " answer
+   project_name=${answer:-$default_name}
+   echo "COMPOSE_PROJECT_NAME=${project_name}" >> .env
    echo "set project name in .env file"
    source .env
 fi
 
-echo "project '$COMPOSE_PROJECT_NAME' ready with default values.  Review or create a docker-compose.override.yml for custom settings."
\ No newline at end of file
+if [ ! -e "docker-compose.yml" ] ; then
+    cp $base/usxs-template.yml ./docker-compose.yml
+    echo "created default docker-compose.yml"
+fi
+
+if [ "$USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_APPLICATIONID" == "" ]
+then
+   read -e -p "Generate USAS and USPS integration config? <Y/n> " answer
+   case $answer in
+        y | Y | yes | YES ) answer="y";;
+        n | N | no | NO ) answer="n";;
+        *) answer="y"
+   esac
+   if [ "$answer" == "y" ] 
+   then
+     usas_id=${COMPOSE_PROJECT_NAME}-usas
+     usas_key=$(openssl rand -hex 32)
+     usps_id=${COMPOSE_PROJECT_NAME}-usps
+     usps_key=$(openssl rand -hex 32)
+     echo "USAS_APPLICATIONID=${usas_id}"   >> .env
+     echo "USAS_APIKEY=$usas_key"           >> .env
+     echo "USPS_APPLICATIONID=${usps_id}"   >> .env
+     echo "USPS_APIKEY=$usps_key"           >> .env
+     echo "Created integration API keys.  Enable integration modules after applications startup"
+   fi
+fi
+
+echo "project '$COMPOSE_PROJECT_NAME' ready with default values.  Review or create a docker-compose.override.yml for custom settings."
+
--- a/compose2/preview/usxs-services.yml	Mon May 08 14:43:56 2017 -0400
+++ b/compose2/preview/usxs-services.yml	Mon May 08 22:13:40 2017 +0100
@@ -26,6 +26,10 @@
       - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_CLIENTDNSLOOKUP=true
       - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_SERVERHOST=0.0.0.0
       - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_CLIENTDNSLOOKUP=false
+      - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_APPLICATIONID=${USAS_APPLICATIONID:- }
+      - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_APIKEY=${USAS_APIKEY:- }
+      - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_REMOTEAPPLICATIONID=${USPS_APPLICATIONID:- }
+      - USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_REMOTEAPIKEY=${USPS_APIKEY:- }
   usasimport-base:
     image: docker.ssdt.io/usas-import:preview
     command: -i ${IMP_IRN- } -u ${IMP_URL- } -r ${IMP_PATH- }
@@ -59,6 +63,10 @@
       - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_CLIENTDNSLOOKUP=true
       - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_CLIENTHOST=0.0.0.0
       - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_CLIENTDNSLOOKUP=false
+      - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_APPLICATIONID=${USPS_APPLICATIONID:- }
+      - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_APIKEY=${USPS_APIKEY:- }
+      - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_REMOTEAPPLICATIONID=${USAS_APPLICATIONID:- }
+      - USPS_MODULE_USASINTEGRATION_CONFIGURATION_USASCONFIGURATION_REMOTEAPIKEY=${USAS_APIKEY:- }
   uspsimport-base:
     image: docker.ssdt.io/usps-import:preview
     command: -i ${IMP_IRN- } -u ${IMP_URL- } -r ${IMP_PATH- } ${IMP_ANON- } ${IMP_EM- }