Mercurial > public > ssdt-docker
annotate scripts/.functions.sh @ 141:06611703da29 production
Added tag v1.1.1 for changeset 73c0c04a44eb
author | smith@nwoca.org |
---|---|
date | Fri, 16 Jun 2017 17:14:15 +0100 |
parents | 85957628f4c0 |
children | 8f45c43ea7a4 |
rev | line source |
---|---|
55
77ff739c078d
add script to provide shortened docker ps with ssdt labels
smith@nwoca.org
parents:
diff
changeset
|
1 #!/bin/bash |
61 | 2 |
73 | 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 } | |
79
85957628f4c0
add script to clear liquibase lock on existing db container
smith@nwoca.org
parents:
73
diff
changeset
|
23 |
85957628f4c0
add script to clear liquibase lock on existing db container
smith@nwoca.org
parents:
73
diff
changeset
|
24 executeSQL() { |
85957628f4c0
add script to clear liquibase lock on existing db container
smith@nwoca.org
parents:
73
diff
changeset
|
25 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
|
26 container=$(composeGetContainer $service) |
85957628f4c0
add script to clear liquibase lock on existing db container
smith@nwoca.org
parents:
73
diff
changeset
|
27 |
85957628f4c0
add script to clear liquibase lock on existing db container
smith@nwoca.org
parents:
73
diff
changeset
|
28 echo "$2" | docker exec -i $container sh -c "gosu postgres psql \$DB_NAME" |
85957628f4c0
add script to clear liquibase lock on existing db container
smith@nwoca.org
parents:
73
diff
changeset
|
29 } |