changeset 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 c1f38cbf1294
children 9832111e8d7c
files scripts/pull-updates.sh scripts/updates-apply.sh scripts/updates-pull.sh
diffstat 3 files changed, 71 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/pull-updates.sh	Mon Feb 22 12:25:41 2016 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-# 
-# Pulls updates from upstream repository for images matching filter. The
-# default filter pulls all ssdt application images.
-#
-# Usage:
-#    pull-updates.sh [application] [filter]
-#
-#    defaults:
-#      application=all applications
-#      filter=label=io.ssdt.app[=application]
-#
-# Note: if filter is provided, the first argument is ignored. A complete filter must be supplied.
-#
-APP=${1:+=$1}
-FILTER=${2:-label=io.ssdt.app$APP}
-while read -a line
-do
-   repo=${line[0]}
-   tag=${line[1]}
-   if [[ $repo == docker.ssdt.io* ]]
-   then
-      echo "docker pull ${repo}:${tag}"
-      docker pull ${repo}:${tag}
-   fi
-done <  <(docker images  --filter "$FILTER")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/updates-apply.sh	Mon Feb 22 17:32:57 2016 -0500
@@ -0,0 +1,46 @@
+
+# Scans for docker projects in specified parent path and
+# updated 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/updates-pull.sh	Mon Feb 22 17:32:57 2016 -0500
@@ -0,0 +1,25 @@
+# 
+# Pulls updates from upstream repository for images matching filter. The
+# default filter pulls all ssdt application images.
+#
+# Usage:
+#    pull-updates.sh [application] [filter]
+#
+#    defaults:
+#      application=all applications
+#      filter=label=io.ssdt.app[=application]
+#
+# Note: if filter is provided, the first argument is ignored. A complete filter must be supplied.
+#
+APP=${1:+=$1}
+FILTER=${2:-label=io.ssdt.app$APP}
+while read -a line
+do
+   repo=${line[0]}
+   tag=${line[1]}
+   if [[ $repo == docker.ssdt.io* ]]
+   then
+      echo "docker pull ${repo}:${tag}"
+      docker pull ${repo}:${tag}
+   fi
+done <  <(docker images  --filter "$FILTER")