comparison scripts/.functions.sh @ 90:63cb9be89a26 production v1.0.0

flow: Merged <release> 'v1.0.0' to <master> ('production').
author smith@nwoca.org
date Thu, 22 Sep 2016 01:49:20 +0100
parents 85957628f4c0
children 8f45c43ea7a4
comparison
equal deleted inserted replaced
1:44f401c902ba 90:63cb9be89a26
1 #!/bin/bash
2
3 # deletes psql data from specified service
4 resetDbVolume() {
5 # Works for named and unnamed volumes and custom $PGDATA.
6 # Container must be stopped
7 service=${1?Must supply db service to reset}
8 container=$(composeGetContainer $service)
9 if [ "$container" != "" ]
10 then
11 echo "deleting db data from $container"
12 docker-compose run --no-deps --rm $service bash -c "rm -rf \${PGDATA?Missing PGDATA env}"
13 fi
14 }
15
16 # finds docker container for specified compose service
17 composeGetContainer() {
18 service=${1?"Must supply service from current project"}
19
20 container=$( docker-compose ps | cut -d " " -f 1 -s | grep _${service}_ )
21 echo $container
22 }
23
24 executeSQL() {
25 service=${1?Must supply db service to execute against}
26 container=$(composeGetContainer $service)
27
28 echo "$2" | docker exec -i $container sh -c "gosu postgres psql \$DB_NAME"
29 }