comparison scripts/exec-all-projects-docker.sh @ 388:23d40b345e1e

INV-197 create db backup helper scripts for inventory and workflow
author Matt Calmes <calmes@ssdt-ohio.org>
date Mon, 18 Oct 2021 06:33:33 -0400
parents
children d75786228e6b
comparison
equal deleted inserted replaced
369:3dc92d4243ef 388:23d40b345e1e
1 #!/bin/bash
2 # Scans for docker projects in specified parent path and
3 # executes the specified command.
4 #
5 # The first parameter specifices theparent directory to search for
6 # docker-compose.yml # files must be specified. #
7 #
8 # the second paramter specifies the command to execute against each
9 # compose project.
10 #
11 # examples:
12 #
13 # /ssdt/scripts/exec-all-projects.sh /data/prod docker-compose ps
14 #
15 # executes "docker-compose ps" against all projects under /data/prod
16 #
17 # /ssdt/scripts/exec-all-projects.sh /data/prod /ssdt/ /ssdt/scripts/backup-usas.sh
18 #
19 # runs backup-usas.sh script against all projects under /data/prod
20 #
21 # /ssdt/scripts/exec-all-projects.sh /data/prod "/ssdt/scripts/capture.sh | /ssdt/scripts/send.sh -"
22 #
23 # captures the log files from all containers and sends one log file per project
24 # to the SSDT support server.
25 #
26 ##
27
28 source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
29
30 : ${1?"Usage: {parent path} [command]"}
31
32 ORIGINALDIR=$PWD
33 PARENTDIR=$1
34
35 shift
36 COMMAND=$@
37
38 for f in $(find $PARENTDIR -type d -name .env)
39 do
40 projectdir=`dirname $f`
41 project=`basename $projectdir`
42 cd $projectdir
43 echo "projectdir is $projectdir"
44 echo -e "----\n$executing $COMMAND on $project \n----"
45
46 #bash -c "${COMMAND}"
47 echo ""
48
49 done
50
51 cd $ORIGINALDIR