annotate scripts/.functions.sh @ 75:aa2fd199ba56

improve pid2name script
author smith@nwoca.org
date Wed, 23 Mar 2016 16:39:31 +0100
parents d2c44193fbaa
children 85957628f4c0
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
cc997ae758c6 add process summary and list
smith@nwoca.org
parents: 59
diff changeset
2
73
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
3 # deletes psql data from specified service
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
4 resetDbVolume() {
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
5 # Works for named and unnamed volumes and custom $PGDATA.
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
6 # Container must be stopped
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
7 service=${1?Must supply db service to reset}
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
8 container=$(composeGetContainer $service)
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
9 if [ "$container" != "" ]
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
10 then
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
11 echo "deleting db data from $container"
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
12 docker-compose run --no-deps --rm $service bash -c "rm -rf \${PGDATA?Missing PGDATA env}"
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
13 fi
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
14 }
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
15
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
16 # finds docker container for specified compose service
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
17 composeGetContainer() {
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
18 service=${1?"Must supply service from current project"}
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
19
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
20 container=$( docker-compose ps | cut -d " " -f 1 -s | grep _${service}_ )
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
21 echo $container
d2c44193fbaa explictly remove db's before import
smith@nwoca.org
parents: 66
diff changeset
22 }