Mercurial > public > ssdt-docker
comparison pilot/setup.sh @ 145:75aa7005b544
DEP-12: move comopse files to 'pilot' location
author | smith@nwoca.org |
---|---|
date | Mon, 10 Jul 2017 18:13:18 +0100 |
parents | compose3/preview/setup.sh@72f15ffc9ad2 |
children | d20c6ff9a821 |
comparison
equal
deleted
inserted
replaced
144:249ec634da33 | 145:75aa7005b544 |
---|---|
1 #!/bin/bash | |
2 # Sets up a new district project based on SSDT default configuration in the current working directory. | |
3 # | |
4 # Usage: | |
5 # | |
6 # /data/preview/sampletown $ /ssdt/compose2/preview/setup.sh [usas,usps...] | |
7 # | |
8 # | |
9 # | |
10 # Will create a docker-compose.yml and .env file with default settings. | |
11 # | |
12 # | |
13 source "$(dirname "${BASH_SOURCE[0]}")/../scripts/.functions.sh" | |
14 | |
15 md5calc() { | |
16 md5sum ${1} ; | |
17 } | |
18 | |
19 md5verify() { | |
20 md5sum -c --status ${1} ; | |
21 } | |
22 | |
23 base=$(dirname "${BASH_SOURCE[0]}") | |
24 default_name=$(basename $PWD) | |
25 | |
26 args="$1$2" | |
27 | |
28 usas="" | |
29 usps="" | |
30 | |
31 if [ "$args" == "" ] || [ -z "${args##*usas*}" ] | |
32 then | |
33 usas=1 | |
34 fi | |
35 | |
36 if [ "$args" == "" ] || [ -z "${args##*usps*}" ] | |
37 then | |
38 usps=1 | |
39 fi | |
40 | |
41 echo "Preparing '$(basename $PWD)' with default USxS configuration" | |
42 | |
43 touch .env | |
44 source .env | |
45 | |
46 if [ "$COMPOSE_PROJECT_NAME" == "" ] | |
47 then | |
48 read -e -p "Enter project name: <${default_name}> " answer | |
49 project_name=${answer:-$default_name} | |
50 echo "COMPOSE_PROJECT_NAME=${project_name}" >> .env | |
51 echo "set project name in .env file" | |
52 source .env | |
53 fi | |
54 | |
55 if [ ! -e "docker-compose.yml" ] | |
56 then | |
57 create="OK" | |
58 elif [ -e ".docker-compose.md5" ]; then | |
59 md5verify ./.docker-compose.md5 && create="OK" | |
60 fi | |
61 | |
62 if [ "$create" == "OK" ] | |
63 then | |
64 echo "version: \"3.1\"" > ./docker-compose.yml | |
65 echo "services:" >> ./docker-compose.yml | |
66 | |
67 [ ! "$usas" == "" ] && cat $base/usas-services.yml >> ./docker-compose.yml | |
68 | |
69 [ ! "$usps" == "" ] && cat $base/usps-services.yml >> ./docker-compose.yml | |
70 | |
71 echo "volumes:" >> ./docker-compose.yml | |
72 | |
73 [ ! "$usas" == "" ] && echo " usasdata:" >> ./docker-compose.yml | |
74 [ ! "$usps" == "" ] && echo " uspsdata:" >> ./docker-compose.yml | |
75 | |
76 echo "" >> ./docker-compose.yml | |
77 | |
78 md5calc ./docker-compose.yml > .docker-compose.md5 | |
79 | |
80 echo "created docker-compose.yml" | |
81 | |
82 else | |
83 echo " | |
84 | |
85 Error! docker-compose.yml file has been modified or checksum missing. Can auto-apply update(s). | |
86 Move customizations to docker-compose.override.yml then delete the docker-compose.yml | |
87 " | |
88 fi | |
89 | |
90 if [ "$USAS_APPLICATIONID" == "" ] | |
91 then | |
92 read -e -p "Generate USAS and USPS integration config? <Y/n> " answer | |
93 case $answer in | |
94 y | Y | yes | YES ) answer="y";; | |
95 n | N | no | NO ) answer="n";; | |
96 *) answer="y" | |
97 esac | |
98 if [ "$answer" == "y" ] | |
99 then | |
100 usas_id=${COMPOSE_PROJECT_NAME}-usas | |
101 usas_key=$(openssl rand -hex 32) | |
102 usps_id=${COMPOSE_PROJECT_NAME}-usps | |
103 usps_key=$(openssl rand -hex 32) | |
104 echo "USAS_APPLICATIONID=${usas_id}" >> .env | |
105 echo "USAS_APIKEY=$usas_key" >> .env | |
106 echo "USPS_APPLICATIONID=${usps_id}" >> .env | |
107 echo "USPS_APIKEY=$usps_key" >> .env | |
108 echo "Created integration API keys. Enable integration modules after applications start" | |
109 fi | |
110 fi | |
111 | |
112 echo "Review or create a docker-compose.override.yml for custom settings." | |
113 |