view scripts/exec-all-projects.sh @ 190:c3587159637f

DEP-12: fix if expression
author smith@nwoca.org
date Wed, 20 Sep 2017 17:41:25 +0100
parents 6b950e1a95e6
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