Mercurial > public > ssdt-docker
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/updates-apply.sh Thu Sep 22 01:49:20 2016 +0100 @@ -0,0 +1,46 @@ +#!/bin/bash +# Scans for docker projects in specified parent path and +# updates images, if applicable. +# +# The parent directory to search for docker-compose.yml +# files must be specified. An optional service to update +# may be specified in the second argument. The default is +# to update services matching "*app". +# +# Only services which are currently running will be updated. +# The script will not automatically start stopped services. +# +# examples: +# /ssdt/apply-updates.sh /data/preview +# /ssdt/apply-updates.sh /data/preview usps +# +: ${1?"Usage: {parent path} [service]"} +SERVICE=${2:-*app} + +ORIGINALDIR=$PWD +PARENTDIR=$1 + +for f in $(find $PARENTDIR -name docker-compose.yml) +do + projectdir=`dirname $f` + project=`basename $projectdir` + cd $projectdir + echo -e "----\n$project: checking services" + while read line + do + read container eol <<< $line + if [[ $container == *_1 ]] + then + t=(${container//_/ }) + service=${t[1]} + if [[ $service == $SERVICE ]] + then + echo -e "\n$project: Updating $service" + docker-compose up -d $service + fi + fi + done < <(docker-compose ps) + +done + +cd $ORIGINALDIR