Mercurial > public > ssdt-docker
comparison scripts/.functions.sh @ 163:daf91a3bbee5 production v1.2.0
flow: Merged <release> 'v1.2.0' to <master> ('production').
author | smith@nwoca.org |
---|---|
date | Tue, 15 Aug 2017 21:59:23 +0100 |
parents | 018f62da1931 |
children | 1a8087653f2a |
comparison
equal
deleted
inserted
replaced
141:06611703da29 | 163:daf91a3bbee5 |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 getScriptDir() { | |
3 SOURCE="${BASH_SOURCE[0]}" | |
4 while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done | |
5 echo $( cd $( dirname $SOURCE) && pwd ) | |
6 } | |
7 | |
8 if [ "$SSDT_HOME" == "" ] | |
9 then | |
10 export SSDT_SCRIPTS=$(getScriptDir) | |
11 export SSDT_HOME=$(dirname $SSDT_SCRIPTS) | |
12 fi | |
13 | |
14 export SSDT_DOCKER_VERSION=$(docker version --format '{{.Server.Version}}') | |
2 | 15 |
3 # deletes psql data from specified service | 16 # deletes psql data from specified service |
4 resetDbVolume() { | 17 resetDbVolume() { |
5 # Works for named and unnamed volumes and custom $PGDATA. | 18 # Works for named and unnamed volumes and custom $PGDATA. |
6 # Container must be stopped | 19 # Container must be stopped |
25 service=${1?Must supply db service to execute against} | 38 service=${1?Must supply db service to execute against} |
26 container=$(composeGetContainer $service) | 39 container=$(composeGetContainer $service) |
27 | 40 |
28 echo "$2" | docker exec -i $container sh -c "gosu postgres psql \$DB_NAME" | 41 echo "$2" | docker exec -i $container sh -c "gosu postgres psql \$DB_NAME" |
29 } | 42 } |
43 | |
44 composeGetProject() { | |
45 service=${1?"Must supply service from current project"} | |
46 container=$(composeGetContainer $service) | |
47 echo $(docker inspect -f '{{index .Config.Labels "com.docker.compose.project" }}' $container) | |
48 } |