changeset 186:620ea742f1df

DEP-12: add script to execute commands against multiple projects.
author smith@nwoca.org
date Wed, 20 Sep 2017 16:52:37 +0100
parents 21eebe9c1a8c
children 6b950e1a95e6
files scripts/backup-container.sh scripts/backup-usps.sh scripts/exec-all-projects.sh
diffstat 3 files changed, 31 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/backup-container.sh	Wed Sep 20 16:19:19 2017 +0100
+++ b/scripts/backup-container.sh	Wed Sep 20 16:52:37 2017 +0100
@@ -23,7 +23,7 @@
 fi
 
 echo "starting backup of $container for $project"
-docker-compose exec $container sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container ; (exit $?) " > ${backupFile}
+docker-compose exec -t $container sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container ; (exit $?) " > ${backupFile}
 
 if [[ $( grep --count "CREATE TABLE" ${backupFile} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile} ) -eq 0 ]]; then
    echo "ERROR: backup verification FAILED"
--- a/scripts/backup-usps.sh	Wed Sep 20 16:19:19 2017 +0100
+++ b/scripts/backup-usps.sh	Wed Sep 20 16:52:37 2017 +0100
@@ -2,5 +2,5 @@
 
 source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
 
-${SSDT_SCRIPTS}/backup-container.sh uspsdb
+${SSDT_SCRIPTS}/backup-container.sh uspsdb ${1}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/exec-all-projects.sh	Wed Sep 20 16:52:37 2017 +0100
@@ -0,0 +1,29 @@
+#!/bin/bash
+# Scans for docker projects in specified parent path and
+# executes the specified command.
+#
+# The first parameter specifices theparent directory to search for 
+# docker-compose.yml # files must be specified.  #
+# 
+# the second paramter specifies the command to execute against each
+# compose project.
+##
+
+: ${1?"Usage: {parent path} [command]"}
+COMMAND=${2:-*app}
+
+ORIGINALDIR=$PWD
+PARENTDIR=$1
+
+for f in $(find $PARENTDIR -name docker-compose.yml)
+do
+   projectdir=`dirname $f`
+   project=`basename $projectdir`
+   cd $projectdir
+   echo -e "----\n$executing $COMMAND on $project"      
+   
+   bash -c ${COMMAND}
+   
+done
+
+cd $ORIGINALDIR