comparison pilot/setup.sh @ 149:ab4effbe8d43

DEP-12: generate unique DB passwords for application databases
author smith@nwoca.org
date Tue, 18 Jul 2017 19:39:38 +0100
parents d20c6ff9a821
children 29c7c4c4e891
comparison
equal deleted inserted replaced
148:d20c6ff9a821 149:ab4effbe8d43
14 md5sum ${1} ; 14 md5sum ${1} ;
15 } 15 }
16 16
17 md5verify() { 17 md5verify() {
18 md5sum -c --status ${1} ; 18 md5sum -c --status ${1} ;
19 }
20
21 genDBHash() {
22 echo $(date +%s%N | sha256sum | base64 | head -c 32 ; echo)
19 } 23 }
20 24
21 base=$(dirname "${BASH_SOURCE[0]}") 25 base=$(dirname "${BASH_SOURCE[0]}")
22 default_name=$(basename $PWD) 26 default_name=$(basename $PWD)
23 27
57 md5verify ./.docker-compose.md5 && create="OK" 61 md5verify ./.docker-compose.md5 && create="OK"
58 fi 62 fi
59 63
60 if [ "$create" == "OK" ] 64 if [ "$create" == "OK" ]
61 then 65 then
62 echo "version: \"3.3\"" > ./docker-compose.yml 66 echo "# **** DO NOT MODIFY THIS FILE. ****" > ./docker-compose.yml
67 echo "# Place customizations in docker-compose.override.yml and .env" >> ./docker-compose.yml
68 echo "version: \"3.3\"" >> ./docker-compose.yml
63 echo "services:" >> ./docker-compose.yml 69 echo "services:" >> ./docker-compose.yml
64 70
65 [ ! "$usas" == "" ] && cat $base/usas-services.yml >> ./docker-compose.yml 71 [ ! "$usas" == "" ] && cat $base/usas-services.yml >> ./docker-compose.yml
66 72
67 [ ! "$usps" == "" ] && cat $base/usps-services.yml >> ./docker-compose.yml 73 [ ! "$usps" == "" ] && cat $base/usps-services.yml >> ./docker-compose.yml
68 74
69 echo "volumes:" >> ./docker-compose.yml 75 echo "volumes:" >> ./docker-compose.yml
70 76
71 [ ! "$usas" == "" ] && echo " usasdata:" >> ./docker-compose.yml 77 if [ ! "$usas" == "" ]
72 [ ! "$usps" == "" ] && echo " uspsdata:" >> ./docker-compose.yml 78 then
73 79 echo " usasdata:" >> ./docker-compose.yml
80 [ "$USAS_DB_PASSWORD" == "" ] && echo "USAS_DB_PASSWORD=$(genDBHash)" >> ./.env
81 fi
82
83 if [ ! "$usps" == "" ]
84 then
85 echo " uspsdata:" >> ./docker-compose.yml
86 [ "$USPS_DB_PASSWORD" == "" ] && echo "USPS_DB_PASSWORD=$(genDBHash)" >> ./.env
87 fi
88
74 echo "" >> ./docker-compose.yml 89 echo "" >> ./docker-compose.yml
75 90
76 md5calc ./docker-compose.yml > .docker-compose.md5 91 md5calc ./docker-compose.yml > .docker-compose.md5
77 92
78 echo "created docker-compose.yml" 93 echo "created docker-compose.yml"
79 94
80 else 95 else
81 echo " 96 echo "