annotate scripts/exec-all-projects.sh @ 186:620ea742f1df

DEP-12: add script to execute commands against multiple projects.
author smith@nwoca.org
date Wed, 20 Sep 2017 16:52:37 +0100
parents scripts/updates-apply.sh@334d65dac778
children 6b950e1a95e6
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.
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
10 ##
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
11
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
12 : ${1?"Usage: {parent path} [command]"}
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
13 COMMAND=${2:-*app}
51
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
14
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
15 ORIGINALDIR=$PWD
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
16 PARENTDIR=$1
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
17
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
18 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
19 do
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
20 projectdir=`dirname $f`
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
21 project=`basename $projectdir`
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
22 cd $projectdir
186
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
23 echo -e "----\n$executing $COMMAND on $project"
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
24
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
25 bash -c ${COMMAND}
620ea742f1df DEP-12: add script to execute commands against multiple projects.
smith@nwoca.org
parents: 54
diff changeset
26
51
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
27 done
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
28
40e10b1d32f7 add script to apply image updates to compose projects
Dave smith <smith@nwoca.org>
parents:
diff changeset
29 cd $ORIGINALDIR