annotate scripts/exec-all-projects.sh @ 429:35fc94e4e080

USASR-5154 set ubuntu version
author belknapSSDT <zach.belknap@mcoecn.org>
date Wed, 27 Sep 2023 13:09:26 -0400
parents f6bea554980e
children
rev   line source
54
334d65dac778 add hash bangs to specify bash shell
smith@nwoca.org
parents: 52
diff changeset
1 #!/bin/bash
51
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
2 # Scans for docker projects in specified parent path and
186
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
3 # executes the specified command.
51
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
4 #
186
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
5 # The first parameter specifices theparent directory to search for
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
6 # docker-compose.yml # files must be specified. #
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
7 #
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
8 # the second paramter specifies the command to execute against each
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
9 # compose project.
191
fea886ba7279 DEP-12: add source for .functions.sh to all scripts using compose
smith@nwoca.org
parents: 187
diff changeset
10 #
fea886ba7279 DEP-12: add source for .functions.sh to all scripts using compose
smith@nwoca.org
parents: 187
diff changeset
11 # examples:
fea886ba7279 DEP-12: add source for .functions.sh to all scripts using compose
smith@nwoca.org
parents: 187
diff changeset
12 #
237
f6bea554980e DEP-14: remove obsolete compose files from preview releases
smith@nwoca.org
parents: 191
diff changeset
13 # /ssdt/scripts/exec-all-projects.sh /data/prod docker-compose ps
191
fea886ba7279 DEP-12: add source for .functions.sh to all scripts using compose
smith@nwoca.org
parents: 187
diff changeset
14 #
237
f6bea554980e DEP-14: remove obsolete compose files from preview releases
smith@nwoca.org
parents: 191
diff changeset
15 # executes "docker-compose ps" against all projects under /data/prod
191
fea886ba7279 DEP-12: add source for .functions.sh to all scripts using compose
smith@nwoca.org
parents: 187
diff changeset
16 #
237
f6bea554980e DEP-14: remove obsolete compose files from preview releases
smith@nwoca.org
parents: 191
diff changeset
17 # /ssdt/scripts/exec-all-projects.sh /data/prod /ssdt/ /ssdt/scripts/backup-usas.sh
191
fea886ba7279 DEP-12: add source for .functions.sh to all scripts using compose
smith@nwoca.org
parents: 187
diff changeset
18 #
237
f6bea554980e DEP-14: remove obsolete compose files from preview releases
smith@nwoca.org
parents: 191
diff changeset
19 # runs backup-usas.sh script against all projects under /data/prod
191
fea886ba7279 DEP-12: add source for .functions.sh to all scripts using compose
smith@nwoca.org
parents: 187
diff changeset
20 #
237
f6bea554980e DEP-14: remove obsolete compose files from preview releases
smith@nwoca.org
parents: 191
diff changeset
21 # /ssdt/scripts/exec-all-projects.sh /data/prod "/ssdt/scripts/capture.sh | /ssdt/scripts/send.sh -"
f6bea554980e DEP-14: remove obsolete compose files from preview releases
smith@nwoca.org
parents: 191
diff changeset
22 #
f6bea554980e DEP-14: remove obsolete compose files from preview releases
smith@nwoca.org
parents: 191
diff changeset
23 # captures the log files from all containers and sends one log file per project
191
fea886ba7279 DEP-12: add source for .functions.sh to all scripts using compose
smith@nwoca.org
parents: 187
diff changeset
24 # to the SSDT support server.
fea886ba7279 DEP-12: add source for .functions.sh to all scripts using compose
smith@nwoca.org
parents: 187
diff changeset
25 #
186
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
26 ##
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
27
191
fea886ba7279 DEP-12: add source for .functions.sh to all scripts using compose
smith@nwoca.org
parents: 187
diff changeset
28 source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
fea886ba7279 DEP-12: add source for .functions.sh to all scripts using compose
smith@nwoca.org
parents: 187
diff changeset
29
186
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
30 : ${1?"Usage: {parent path} [command]"}
51
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
31
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
32 ORIGINALDIR=$PWD
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
33 PARENTDIR=$1
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
34
187
6b950e1a95e6 DEP-12: update exec script.
smith@nwoca.org
parents: 186
diff changeset
35 shift
6b950e1a95e6 DEP-12: update exec script.
smith@nwoca.org
parents: 186
diff changeset
36 COMMAND=$@
6b950e1a95e6 DEP-12: update exec script.
smith@nwoca.org
parents: 186
diff changeset
37
51
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
38 for f in $(find $PARENTDIR -name docker-compose.yml)
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
39 do
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
40 projectdir=`dirname $f`
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
41 project=`basename $projectdir`
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
42 cd $projectdir
187
6b950e1a95e6 DEP-12: update exec script.
smith@nwoca.org
parents: 186
diff changeset
43 echo -e "----\n$executing $COMMAND on $project \n----"
191
fea886ba7279 DEP-12: add source for .functions.sh to all scripts using compose
smith@nwoca.org
parents: 187
diff changeset
44
187
6b950e1a95e6 DEP-12: update exec script.
smith@nwoca.org
parents: 186
diff changeset
45 bash -c "${COMMAND}"
6b950e1a95e6 DEP-12: update exec script.
smith@nwoca.org
parents: 186
diff changeset
46 echo ""
191
fea886ba7279 DEP-12: add source for .functions.sh to all scripts using compose
smith@nwoca.org
parents: 187
diff changeset
47
51
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
48 done
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
49
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
50 cd $ORIGINALDIR