diff compose3/preview/setup.sh @ 135:03e39b95d904

DEP-12: convert to compose verison 3.1 (again)
author smith@nwoca.org
date Mon, 15 May 2017 21:33:24 +0100
parents compose2/preview/setup.sh@48c5b742016c
children 72f15ffc9ad2
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compose3/preview/setup.sh	Mon May 15 21:33:24 2017 +0100
@@ -0,0 +1,80 @@
+#!/bin/bash
+# Sets up a new district project based on SSDT default configuration in the current working directory.
+#
+# Usage:
+#
+#  /data/preview/sampletown $   /ssdt/compose2/preview/setup.sh [usas,usps...] 
+#
+# 
+#
+# Will create a docker-compose.yml and .env file with default settings.
+#
+# 
+source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/.functions.sh"
+
+base=$(dirname "${BASH_SOURCE[0]}")
+default_name=$(basename $PWD)
+
+args="$1$2"
+
+usas=0
+usps=0
+
+if [ "$args" == "" ] || [ -z "${args##*usas*}" ]
+then
+   usas=1
+fi
+
+if [ "$args" == "" ] || [ -z "${args##*usps*}" ]
+then
+   usps=1
+fi
+
+echo "args: $args usas: $usas usps: $usps"
+
+exit 
+
+
+echo "Preparing '$(basename $PWD)' with default USxS configuration" 
+
+touch .env
+source .env
+
+if [ "$COMPOSE_PROJECT_NAME" == "" ]
+then
+   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
+
+if [ ! -e "docker-compose.yml" ] ; then
+    cp $base/usxs-template.yml ./docker-compose.yml
+    echo "created default docker-compose.yml"
+fi
+
+if [ "$USAS_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."
+