comparison scripts/updates-apply.sh @ 90:63cb9be89a26 production v1.0.0

flow: Merged <release> 'v1.0.0' to <master> ('production').
author smith@nwoca.org
date Thu, 22 Sep 2016 01:49:20 +0100
parents 334d65dac778
children fea886ba7279
comparison
equal deleted inserted replaced
1:44f401c902ba 90:63cb9be89a26
1 #!/bin/bash
2 # Scans for docker projects in specified parent path and
3 # updates images, if applicable.
4 #
5 # The parent directory to search for docker-compose.yml
6 # files must be specified. An optional service to update
7 # may be specified in the second argument. The default is
8 # to update services matching "*app".
9 #
10 # Only services which are currently running will be updated.
11 # The script will not automatically start stopped services.
12 #
13 # examples:
14 # /ssdt/apply-updates.sh /data/preview
15 # /ssdt/apply-updates.sh /data/preview usps
16 #
17 : ${1?"Usage: {parent path} [service]"}
18 SERVICE=${2:-*app}
19
20 ORIGINALDIR=$PWD
21 PARENTDIR=$1
22
23 for f in $(find $PARENTDIR -name docker-compose.yml)
24 do
25 projectdir=`dirname $f`
26 project=`basename $projectdir`
27 cd $projectdir
28 echo -e "----\n$project: checking services"
29 while read line
30 do
31 read container eol <<< $line
32 if [[ $container == *_1 ]]
33 then
34 t=(${container//_/ })
35 service=${t[1]}
36 if [[ $service == $SERVICE ]]
37 then
38 echo -e "\n$project: Updating $service"
39 docker-compose up -d $service
40 fi
41 fi
42 done < <(docker-compose ps)
43
44 done
45
46 cd $ORIGINALDIR