diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/exec-all-projects-docker.sh	Mon Oct 18 06:33:33 2021 -0400
@@ -0,0 +1,51 @@
+#!/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/prod docker-compose ps
+# 
+#     executes "docker-compose ps" against all projects under /data/prod
+#
+#   /ssdt/scripts/exec-all-projects.sh /data/prod /ssdt/ /ssdt/scripts/backup-usas.sh
+#
+#     runs backup-usas.sh script against all projects under /data/prod
+#
+#   /ssdt/scripts/exec-all-projects.sh /data/prod "/ssdt/scripts/capture.sh | /ssdt/scripts/send.sh -"
+#
+#       captures the log files from all containers and sends one log 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 -type d -name .env)
+do
+   projectdir=`dirname $f`
+   project=`basename $projectdir`
+   cd $projectdir
+   echo "projectdir is $projectdir"
+   echo -e "----\n$executing $COMMAND on $project \n----"      
+
+   #bash -c "${COMMAND}"
+   echo ""
+
+done
+
+cd $ORIGINALDIR