comparison scripts/updates-apply.sh @ 51:40e10b1d32f7

add script to apply image updates to compose projects
author Dave smith <smith@nwoca.org>
date Mon, 22 Feb 2016 17:32:57 -0500
parents
children 9832111e8d7c
comparison
equal deleted inserted replaced
50:c1f38cbf1294 51:40e10b1d32f7
1
2 # Scans for docker projects in specified parent path and
3 # updated 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