Mercurial > public > ssdt-docker
annotate compose2/preview/setup.sh @ 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 | bf5f8acc35f2 |
children | 48c5b742016c |
rev | line source |
---|---|
129
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
1 #!/bin/bash |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
2 # Sets up a new district project based on SSDT default configuration in the current working directory. |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
3 # |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
4 # Usage: |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
5 # |
130 | 6 # /data/preview/sampletown $ /ssdt/compose2/preview/setup.sh |
129
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
7 # |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
8 # Will create a docker-compose.yml and .env file with default settings. |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
9 # |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
10 # |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
11 source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/.functions.sh" |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
12 |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
13 base=$(dirname "${BASH_SOURCE[0]}") |
132
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
14 default_name=$(basename $PWD) |
129
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
15 |
130 | 16 echo "Preparing '$(basename $PWD)' with default USxS configuration" |
17 | |
129
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
18 touch .env |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
19 source .env |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
20 |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
21 if [ "$COMPOSE_PROJECT_NAME" == "" ] |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
22 then |
132
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
23 read -e -p "Enter project name: <${default_name}> " answer |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
24 project_name=${answer:-$default_name} |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
25 echo "COMPOSE_PROJECT_NAME=${project_name}" >> .env |
129
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
26 echo "set project name in .env file" |
130 | 27 source .env |
129
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
28 fi |
130 | 29 |
132
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
30 if [ ! -e "docker-compose.yml" ] ; then |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
31 cp $base/usxs-template.yml ./docker-compose.yml |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
32 echo "created default docker-compose.yml" |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
33 fi |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
34 |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
35 if [ "$USAS_MODULE_USPSINTEGRATION_CONFIGURATION_USPSCONFIGURATION_APPLICATIONID" == "" ] |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
36 then |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
37 read -e -p "Generate USAS and USPS integration config? <Y/n> " answer |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
38 case $answer in |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
39 y | Y | yes | YES ) answer="y";; |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
40 n | N | no | NO ) answer="n";; |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
41 *) answer="y" |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
42 esac |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
43 if [ "$answer" == "y" ] |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
44 then |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
45 usas_id=${COMPOSE_PROJECT_NAME}-usas |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
46 usas_key=$(openssl rand -hex 32) |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
47 usps_id=${COMPOSE_PROJECT_NAME}-usps |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
48 usps_key=$(openssl rand -hex 32) |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
49 echo "USAS_APPLICATIONID=${usas_id}" >> .env |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
50 echo "USAS_APIKEY=$usas_key" >> .env |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
51 echo "USPS_APPLICATIONID=${usps_id}" >> .env |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
52 echo "USPS_APIKEY=$usps_key" >> .env |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
53 echo "Created integration API keys. Enable integration modules after applications startup" |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
54 fi |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
55 fi |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
56 |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
57 echo "project '$COMPOSE_PROJECT_NAME' ready with default values. Review or create a docker-compose.override.yml for custom settings." |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
58 |