Mercurial > public > ssdt-docker
annotate scripts/.functions.sh @ 108:b2b23cdaabcd feature/djs-DEP-12-docker
DEP-12: convert to v2.
author | smith@nwoca.org |
---|---|
date | Fri, 21 Apr 2017 20:42:18 +0100 |
parents | 8f45c43ea7a4 |
children | c029be781d13 |
rev | line source |
---|---|
55
77ff739c078d
add script to provide shortened docker ps with ssdt labels
smith@nwoca.org
parents:
diff
changeset
|
1 #!/bin/bash |
85
8f45c43ea7a4
DEP-12: start upgrading scripts and compose files for RC and docker 1.12
Dave Smith <smith@nwoca.org>
parents:
79
diff
changeset
|
2 export SSDT_SCRIPTS=$(dirname "${BASH_SOURCE[0]}") |
8f45c43ea7a4
DEP-12: start upgrading scripts and compose files for RC and docker 1.12
Dave Smith <smith@nwoca.org>
parents:
79
diff
changeset
|
3 export SSDT_HOME=$(dirname $SSDT_SCRIPTS) |
61 | 4 |
73 | 5 # deletes psql data from specified service |
6 resetDbVolume() { | |
7 # Works for named and unnamed volumes and custom $PGDATA. | |
8 # Container must be stopped | |
9 service=${1?Must supply db service to reset} | |
10 container=$(composeGetContainer $service) | |
11 if [ "$container" != "" ] | |
12 then | |
13 echo "deleting db data from $container" | |
14 docker-compose run --no-deps --rm $service bash -c "rm -rf \${PGDATA?Missing PGDATA env}" | |
15 fi | |
16 } | |
17 | |
18 # finds docker container for specified compose service | |
19 composeGetContainer() { | |
20 service=${1?"Must supply service from current project"} | |
21 | |
22 container=$( docker-compose ps | cut -d " " -f 1 -s | grep _${service}_ ) | |
23 echo $container | |
24 } | |
79
85957628f4c0
add script to clear liquibase lock on existing db container
smith@nwoca.org
parents:
73
diff
changeset
|
25 |
85957628f4c0
add script to clear liquibase lock on existing db container
smith@nwoca.org
parents:
73
diff
changeset
|
26 executeSQL() { |
85957628f4c0
add script to clear liquibase lock on existing db container
smith@nwoca.org
parents:
73
diff
changeset
|
27 service=${1?Must supply db service to execute against} |
85957628f4c0
add script to clear liquibase lock on existing db container
smith@nwoca.org
parents:
73
diff
changeset
|
28 container=$(composeGetContainer $service) |
85957628f4c0
add script to clear liquibase lock on existing db container
smith@nwoca.org
parents:
73
diff
changeset
|
29 |
85957628f4c0
add script to clear liquibase lock on existing db container
smith@nwoca.org
parents:
73
diff
changeset
|
30 echo "$2" | docker exec -i $container sh -c "gosu postgres psql \$DB_NAME" |
85
8f45c43ea7a4
DEP-12: start upgrading scripts and compose files for RC and docker 1.12
Dave Smith <smith@nwoca.org>
parents:
79
diff
changeset
|
31 } |
8f45c43ea7a4
DEP-12: start upgrading scripts and compose files for RC and docker 1.12
Dave Smith <smith@nwoca.org>
parents:
79
diff
changeset
|
32 |
8f45c43ea7a4
DEP-12: start upgrading scripts and compose files for RC and docker 1.12
Dave Smith <smith@nwoca.org>
parents:
79
diff
changeset
|
33 composeGetProject() { |
8f45c43ea7a4
DEP-12: start upgrading scripts and compose files for RC and docker 1.12
Dave Smith <smith@nwoca.org>
parents:
79
diff
changeset
|
34 service=${1?"Must supply service from current project"} |
8f45c43ea7a4
DEP-12: start upgrading scripts and compose files for RC and docker 1.12
Dave Smith <smith@nwoca.org>
parents:
79
diff
changeset
|
35 container=$(composeGetContainer $service) |
8f45c43ea7a4
DEP-12: start upgrading scripts and compose files for RC and docker 1.12
Dave Smith <smith@nwoca.org>
parents:
79
diff
changeset
|
36 echo $(docker inspect -f '{{index .Config.Labels "com.docker.compose.project" }}' $container) |
8f45c43ea7a4
DEP-12: start upgrading scripts and compose files for RC and docker 1.12
Dave Smith <smith@nwoca.org>
parents:
79
diff
changeset
|
37 } |