annotate pilot/training.sh @ 271:0032d099a2d5 production v2.2.0

flow: Merged <release> 'v2.2.0' to <master> ('production').
author smith@nwoca.org
date Mon, 12 Nov 2018 21:24:15 +0000
parents 6f97f65c6cb6
children
rev   line source
129
5c986cbb22b8 DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff changeset
1 #!/bin/bash
212
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
2 # Sets up a new Training project based on SSDT default configuration in the current working directory.
129
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 #
212
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
6 # /data/preview/training-01 $ /ssdt/compose2/preview/training.sh
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
7 #
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
8 # Will create a docker-compose.yml and .env file with default settings using the SSDT
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
9 # supplied training database
135
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
10 #
212
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
11 # These are special database images which recreates the database each time the container is created.
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
12 # Therefore, it is very easy to reset the training database simply by deleting the
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
13 # project containers and restarting them. for example:
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
14 #
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
15 # docker-compose down
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
16 # docker-compose up -d
129
5c986cbb22b8 DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff changeset
17 #
145
75aa7005b544 DEP-12: move comopse files to 'pilot' location
smith@nwoca.org
parents: 136
diff changeset
18 source "$(dirname "${BASH_SOURCE[0]}")/../scripts/.functions.sh"
129
5c986cbb22b8 DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff changeset
19
136
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
20 md5calc() {
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
21 md5sum ${1} ;
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
22 }
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
23
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
24 md5verify() {
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
25 md5sum -c --status ${1} ;
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
26 }
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
27
149
ab4effbe8d43 DEP-12: generate unique DB passwords for application databases
smith@nwoca.org
parents: 148
diff changeset
28 genDBHash() {
ab4effbe8d43 DEP-12: generate unique DB passwords for application databases
smith@nwoca.org
parents: 148
diff changeset
29 echo $(date +%s%N | sha256sum | base64 | head -c 32 ; echo)
ab4effbe8d43 DEP-12: generate unique DB passwords for application databases
smith@nwoca.org
parents: 148
diff changeset
30 }
ab4effbe8d43 DEP-12: generate unique DB passwords for application databases
smith@nwoca.org
parents: 148
diff changeset
31
129
5c986cbb22b8 DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff changeset
32 base=$(dirname "${BASH_SOURCE[0]}")
132
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
33 default_name=$(basename $PWD)
129
5c986cbb22b8 DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff changeset
34
135
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
35 args="$1$2"
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
36
136
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
37 usas=""
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
38 usps=""
135
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
39
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
40 if [ "$args" == "" ] || [ -z "${args##*usas*}" ]
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
41 then
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
42 usas=1
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
43 fi
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
44
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
45 if [ "$args" == "" ] || [ -z "${args##*usps*}" ]
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
46 then
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
47 usps=1
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
48 fi
03e39b95d904 DEP-12: convert to compose verison 3.1 (again)
smith@nwoca.org
parents: 134
diff changeset
49
212
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
50 echo "Preparing training project '$(basename $PWD)' with default USxS configuration"
130
bf5f8acc35f2 DEP-12: improve compse setup.sh
smith@nwoca.org
parents: 129
diff changeset
51
129
5c986cbb22b8 DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff changeset
52 touch .env
5c986cbb22b8 DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff changeset
53 source .env
5c986cbb22b8 DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff changeset
54
214
6f97f65c6cb6 DEP-12: update project name to always use default
smith@nwoca.org
parents: 212
diff changeset
55 project_name=${default_name}
6f97f65c6cb6 DEP-12: update project name to always use default
smith@nwoca.org
parents: 212
diff changeset
56
129
5c986cbb22b8 DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff changeset
57 if [ "$COMPOSE_PROJECT_NAME" == "" ]
5c986cbb22b8 DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff changeset
58 then
132
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
59 echo "COMPOSE_PROJECT_NAME=${project_name}" >> .env
130
bf5f8acc35f2 DEP-12: improve compse setup.sh
smith@nwoca.org
parents: 129
diff changeset
60 source .env
129
5c986cbb22b8 DEP-12: add simple script to standardize setting up projects
smith@nwoca.org
parents:
diff changeset
61 fi
130
bf5f8acc35f2 DEP-12: improve compse setup.sh
smith@nwoca.org
parents: 129
diff changeset
62
136
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
63 if [ ! -e "docker-compose.yml" ]
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
64 then
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
65 create="OK"
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
66 elif [ -e ".docker-compose.md5" ]; then
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
67 md5verify ./.docker-compose.md5 && create="OK"
132
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
68 fi
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
69
136
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
70 if [ "$create" == "OK" ]
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
71 then
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
72
212
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
73 cat $base/training.yml > ./docker-compose.yml
136
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
74 echo "" >> ./docker-compose.yml
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
75
149
ab4effbe8d43 DEP-12: generate unique DB passwords for application databases
smith@nwoca.org
parents: 148
diff changeset
76 md5calc ./docker-compose.yml > .docker-compose.md5
136
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
77
212
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
78 echo "created docker-compose.yml for training instance ${project_name}"
166
29c7c4c4e891 if missing, create override file with correct version
smith@nwoca.org
parents: 149
diff changeset
79
136
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
80 else
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
81 echo "
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
82
148
d20c6ff9a821 DEP-12: upgrade to compose format 3.3
smith@nwoca.org
parents: 145
diff changeset
83 Error! docker-compose.yml file has been modified or checksum missing. Can not auto-apply update(s).
136
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
84 Move customizations to docker-compose.override.yml then delete the docker-compose.yml
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
85 "
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
86 fi
166
29c7c4c4e891 if missing, create override file with correct version
smith@nwoca.org
parents: 149
diff changeset
87
29c7c4c4e891 if missing, create override file with correct version
smith@nwoca.org
parents: 149
diff changeset
88 if [ ! -e "docker-compose.override.yml" ]
29c7c4c4e891 if missing, create override file with correct version
smith@nwoca.org
parents: 149
diff changeset
89 then
29c7c4c4e891 if missing, create override file with correct version
smith@nwoca.org
parents: 149
diff changeset
90 echo 'version: "3.3"' >> docker-compose.override.yml
29c7c4c4e891 if missing, create override file with correct version
smith@nwoca.org
parents: 149
diff changeset
91 fi
29c7c4c4e891 if missing, create override file with correct version
smith@nwoca.org
parents: 149
diff changeset
92
134
48c5b742016c DEP-12: correct guard expression on integration keys
smith@nwoca.org
parents: 132
diff changeset
93 if [ "$USAS_APPLICATIONID" == "" ]
132
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
94 then
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
95 usas_id=${COMPOSE_PROJECT_NAME}-usas
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
96 usas_key=$(openssl rand -hex 32)
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
97 usps_id=${COMPOSE_PROJECT_NAME}-usps
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
98 usps_key=$(openssl rand -hex 32)
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
99 echo "USAS_APPLICATIONID=${usas_id}" >> .env
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
100 echo "USAS_APIKEY=$usas_key" >> .env
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
101 echo "USPS_APPLICATIONID=${usps_id}" >> .env
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
102 echo "USPS_APIKEY=$usps_key" >> .env
136
72f15ffc9ad2 DEP-12: convert compose files to 3.1. remove template. update bash script to create composite docker-files without extends. prevent overwriting manual changes to docker-comose.yml
smith@nwoca.org
parents: 135
diff changeset
103 echo "Created integration API keys. Enable integration modules after applications start"
132
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
104 fi
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
105
172
65ad866531d3 USPSR-2856: create alias for apps in default network to allow integraation to use default network (instead of proxy, or other network)
smith@nwoca.org
parents: 166
diff changeset
106 if [ "$USAS_APP_HOST" == "" ]
65ad866531d3 USPSR-2856: create alias for apps in default network to allow integraation to use default network (instead of proxy, or other network)
smith@nwoca.org
parents: 166
diff changeset
107 then
65ad866531d3 USPSR-2856: create alias for apps in default network to allow integraation to use default network (instead of proxy, or other network)
smith@nwoca.org
parents: 166
diff changeset
108 echo "USAS_APP_HOST=usasapp-svr" >> .env
65ad866531d3 USPSR-2856: create alias for apps in default network to allow integraation to use default network (instead of proxy, or other network)
smith@nwoca.org
parents: 166
diff changeset
109 fi
65ad866531d3 USPSR-2856: create alias for apps in default network to allow integraation to use default network (instead of proxy, or other network)
smith@nwoca.org
parents: 166
diff changeset
110
65ad866531d3 USPSR-2856: create alias for apps in default network to allow integraation to use default network (instead of proxy, or other network)
smith@nwoca.org
parents: 166
diff changeset
111 if [ "$USPS_APP_HOST" == "" ]
65ad866531d3 USPSR-2856: create alias for apps in default network to allow integraation to use default network (instead of proxy, or other network)
smith@nwoca.org
parents: 166
diff changeset
112 then
65ad866531d3 USPSR-2856: create alias for apps in default network to allow integraation to use default network (instead of proxy, or other network)
smith@nwoca.org
parents: 166
diff changeset
113 echo "USPS_APP_HOST=uspsapp-svr" >> .env
65ad866531d3 USPSR-2856: create alias for apps in default network to allow integraation to use default network (instead of proxy, or other network)
smith@nwoca.org
parents: 166
diff changeset
114 fi
65ad866531d3 USPSR-2856: create alias for apps in default network to allow integraation to use default network (instead of proxy, or other network)
smith@nwoca.org
parents: 166
diff changeset
115
212
4de5e1a4637c DEP-12: add training.yml and training.sh setup script for pilot training instances
smith@nwoca.org
parents: 173
diff changeset
116 echo "Review or create docker-compose.override.yml for custom settings."
132
a095257a342b DEP-12: add auto-config of initial integration keys
smith@nwoca.org
parents: 130
diff changeset
117