# HG changeset patch # User smith@nwoca.org # Date 1458595075 -3600 # Node ID d2c44193fbaa9885d8e43d2e3a6f2f5dd1f8e334 # Parent 6f562946db805c7435423f86a15d078a11cab624 explictly remove db's before import diff -r 6f562946db80 -r d2c44193fbaa scripts/.functions.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/.functions.sh Mon Mar 21 22:17:55 2016 +0100 @@ -0,0 +1,22 @@ +#!/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 +} diff -r 6f562946db80 -r d2c44193fbaa scripts/capture.sh --- a/scripts/capture.sh Fri Mar 18 01:45:42 2016 +0100 +++ b/scripts/capture.sh Mon Mar 21 22:17:55 2016 +0100 @@ -1,3 +1,3 @@ #!/bin/bash # writes tail of current logs to standard out from running containers in compose project. -docker-compose ps -q | xargs -I ID docker inspect --format='{{.LogPath}}' ID | xargs tail -n8000 +docker-compose ps -q | xargs -I ID docker inspect --format='{{.LogPath}}' ID | xargs tail -n${1-8000} diff -r 6f562946db80 -r d2c44193fbaa scripts/import-usas.sh --- a/scripts/import-usas.sh Fri Mar 18 01:45:42 2016 +0100 +++ b/scripts/import-usas.sh Mon Mar 21 22:17:55 2016 +0100 @@ -1,6 +1,9 @@ #!/bin/bash +source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh" + docker-compose stop usasapp usasdb +resetDbVolume usasdb docker-compose rm -vf usasapp usasdb export IMP_IRN=${IMP_IRN} diff -r 6f562946db80 -r d2c44193fbaa scripts/import-usps.sh --- a/scripts/import-usps.sh Fri Mar 18 01:45:42 2016 +0100 +++ b/scripts/import-usps.sh Mon Mar 21 22:17:55 2016 +0100 @@ -1,6 +1,9 @@ #!/bin/bash +source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh" + docker-compose stop uspsapp uspsdb +resetDbVolume uspsdb docker-compose rm -vf uspsapp uspsdb export IMP_IRN=${IMP_IRN} @@ -16,4 +19,3 @@ docker-compose -f docker-compose.yml -f /ssdt/compose/preview/import.yml rm -f uspsimport # start application docker-compose up -d uspsapp -