view scripts/exec-all-projects.sh @ 187:6b950e1a95e6

DEP-12: update exec script.
author smith@nwoca.org
date Wed, 20 Sep 2017 16:57:30 +0100
parents 620ea742f1df
children fea886ba7279
line wrap: on
line source
#!/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]"}

ORIGINALDIR=$PWD
PARENTDIR=$1

shift
COMMAND=$@

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 \n----"      
   
   bash -c "${COMMAND}"
   echo ""
   
done

cd $ORIGINALDIR