comparison 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
comparison
equal deleted inserted replaced
134:48c5b742016c 135:03e39b95d904
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 base=$(dirname "${BASH_SOURCE[0]}")
16 default_name=$(basename $PWD)
17
18 args="$1$2"
19
20 usas=0
21 usps=0
22
23 if [ "$args" == "" ] || [ -z "${args##*usas*}" ]
24 then
25 usas=1
26 fi
27
28 if [ "$args" == "" ] || [ -z "${args##*usps*}" ]
29 then
30 usps=1
31 fi
32
33 echo "args: $args usas: $usas usps: $usps"
34
35 exit
36
37
38 echo "Preparing '$(basename $PWD)' with default USxS configuration"
39
40 touch .env
41 source .env
42
43 if [ "$COMPOSE_PROJECT_NAME" == "" ]
44 then
45 read -e -p "Enter project name: <${default_name}> " answer
46 project_name=${answer:-$default_name}
47 echo "COMPOSE_PROJECT_NAME=${project_name}" >> .env
48 echo "set project name in .env file"
49 source .env
50 fi
51
52 if [ ! -e "docker-compose.yml" ] ; then
53 cp $base/usxs-template.yml ./docker-compose.yml
54 echo "created default docker-compose.yml"
55 fi
56
57 if [ "$USAS_APPLICATIONID" == "" ]
58 then
59 read -e -p "Generate USAS and USPS integration config? <Y/n> " answer
60 case $answer in
61 y | Y | yes | YES ) answer="y";;
62 n | N | no | NO ) answer="n";;
63 *) answer="y"
64 esac
65 if [ "$answer" == "y" ]
66 then
67 usas_id=${COMPOSE_PROJECT_NAME}-usas
68 usas_key=$(openssl rand -hex 32)
69 usps_id=${COMPOSE_PROJECT_NAME}-usps
70 usps_key=$(openssl rand -hex 32)
71 echo "USAS_APPLICATIONID=${usas_id}" >> .env
72 echo "USAS_APIKEY=$usas_key" >> .env
73 echo "USPS_APPLICATIONID=${usps_id}" >> .env
74 echo "USPS_APIKEY=$usps_key" >> .env
75 echo "Created integration API keys. Enable integration modules after applications startup"
76 fi
77 fi
78
79 echo "project '$COMPOSE_PROJECT_NAME' ready with default values. Review or create a docker-compose.override.yml for custom settings."
80