Mercurial > public > ssdt-docker
annotate 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 |
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 # |
135
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
6 # /data/preview/sampletown $ /ssdt/compose2/preview/setup.sh [usas,usps...] |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
7 # |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
8 # |
129
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 # 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
|
11 # |
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 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
|
14 |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
15 base=$(dirname "${BASH_SOURCE[0]}") |
132
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
16 default_name=$(basename $PWD) |
129
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
17 |
135
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
18 args="$1$2" |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
19 |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
20 usas=0 |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
21 usps=0 |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
22 |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
23 if [ "$args" == "" ] || [ -z "${args##*usas*}" ] |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
24 then |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
25 usas=1 |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
26 fi |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
27 |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
28 if [ "$args" == "" ] || [ -z "${args##*usps*}" ] |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
29 then |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
30 usps=1 |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
31 fi |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
32 |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
33 echo "args: $args usas: $usas usps: $usps" |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
34 |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
35 exit |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
36 |
03e39b95d904
DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents:
134
diff
changeset
|
37 |
130 | 38 echo "Preparing '$(basename $PWD)' with default USxS configuration" |
39 | |
129
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
40 touch .env |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
41 source .env |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
42 |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
43 if [ "$COMPOSE_PROJECT_NAME" == "" ] |
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
44 then |
132
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
45 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
|
46 project_name=${answer:-$default_name} |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
47 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
|
48 echo "set project name in .env file" |
130 | 49 source .env |
129
5c986cbb22b8
DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff
changeset
|
50 fi |
130 | 51 |
132
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
52 if [ ! -e "docker-compose.yml" ] ; then |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
53 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
|
54 echo "created default docker-compose.yml" |
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 |
134
48c5b742016c
DEP-12: correct guard expression on integration keys
smith@nwoca.org
parents:
132
diff
changeset
|
57 if [ "$USAS_APPLICATIONID" == "" ] |
132
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
58 then |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
59 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
|
60 case $answer in |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
61 y | Y | yes | YES ) answer="y";; |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
62 n | N | no | NO ) answer="n";; |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
63 *) answer="y" |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
64 esac |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
65 if [ "$answer" == "y" ] |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
66 then |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
67 usas_id=${COMPOSE_PROJECT_NAME}-usas |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
68 usas_key=$(openssl rand -hex 32) |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
69 usps_id=${COMPOSE_PROJECT_NAME}-usps |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
70 usps_key=$(openssl rand -hex 32) |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
71 echo "USAS_APPLICATIONID=${usas_id}" >> .env |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
72 echo "USAS_APIKEY=$usas_key" >> .env |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
73 echo "USPS_APPLICATIONID=${usps_id}" >> .env |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
74 echo "USPS_APIKEY=$usps_key" >> .env |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
75 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
|
76 fi |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
77 fi |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
78 |
a095257a342b
DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents:
130
diff
changeset
|
79 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
|
80 |