view scripts/exec-all-projects-docker.sh @ 600:3aefc8f43bb4 release/2.22.0

flow: Closed <release> '2.22.0'.
author Marc Davis <marc.davis@mcoecn.org>
date Tue, 17 Sep 2024 08:26:02 -0400
parents b3ff6b33a9c5
children
line wrap: on
line source
#!/bin/bash
# Scans for standard SSDT docker projects in specified parent path and
# executes the specified command.
#
# The first parameter specifies the parent directory to search for.
# 
# The second parameter specifies the command to execute against each
# SSDT standard docker project found under the parent directory.
#
# examples:
#
#   /ssdt/scripts/exec-all-projects-docker.sh /data/prod /ssdt/scripts/backup-inventory.sh
#
#     runs backup-inventory.sh script against all projects under /data/prod
#
##

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 -type d -name .env)
do
   projectdir=`dirname $f`
   project=`basename $projectdir`
   cd $projectdir
   if ls .env/*-shared.properties 1> /dev/null 2>&1; then
      echo "projectdir is $projectdir"
      echo -e "----\n$executing $COMMAND on $project \n----"

      bash -c "${COMMAND}"
      echo ""
   fi
done

cd $ORIGINALDIR