Mercurial > public > ssdt-docker
view scripts/.functions.sh @ 139:9aabd0f7d165 hotfix/v1.1.1
flow: Closed <hotfix> 'v1.1.1'.
author | smith@nwoca.org |
---|---|
date | Fri, 16 Jun 2017 17:14:15 +0100 |
parents | 85957628f4c0 |
children | 8f45c43ea7a4 |
line wrap: on
line source
#!/bin/bash # deletes psql data from specified service resetDbVolume() { # Works for named and unnamed volumes and custom $PGDATA. # Container must be stopped service=${1?Must supply db service to reset} container=$(composeGetContainer $service) if [ "$container" != "" ] then echo "deleting db data from $container" docker-compose run --no-deps --rm $service bash -c "rm -rf \${PGDATA?Missing PGDATA env}" fi } # finds docker container for specified compose service composeGetContainer() { service=${1?"Must supply service from current project"} container=$( docker-compose ps | cut -d " " -f 1 -s | grep _${service}_ ) echo $container } executeSQL() { service=${1?Must supply db service to execute against} container=$(composeGetContainer $service) echo "$2" | docker exec -i $container sh -c "gosu postgres psql \$DB_NAME" }