view scripts/exec-all-projects.sh @ 193:0f1bb8893cc6 release/v1.3.0

flow: Closed <release> 'v1.3.0'.
author smith@nwoca.org
date Thu, 21 Sep 2017 17:14:46 +0100
parents fea886ba7279
children f6bea554980e
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.
#
# examples:
#
#   /ssdt/scripts/exec-all-projects.sh /data/pilot docker-compose ps
# 
#     executes "docker-compose ps" against all projects under /data/pilot
#
#   /ssdt/scripts/exec-all-projects.sh /data/pilot /ssdt/ /ssdt/scripts/backup-usas.sh
#
#     runs backup-usas.sh script against all projects under /data/pilot
#
#   /ssdt/scripts/exec-all-projects.sh /data/pilot "/ssdt/scripts/capture.sh | /ssdt/scripts/send.sh -"
#
#       captures the log files from all containers and sends one long file per project 
#       to the SSDT support server.
#
#
##

source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"

: ${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