diff scripts/exec-all-projects.sh @ 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 scripts/updates-apply.sh@334d65dac778
children 6b950e1a95e6
line wrap: on
line diff
--- /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