view scripts/updates-apply.sh @ 539:5d5525414c8d production tip

update exec-all-projects-docker.sh to search for ./env/*-shared.properties in place of ./env/ssdt-*-shared.properties. ESS doesn't follow the same pattern for property file names.
author Marc Davis <marc.davis@mcoecn.org>
date Mon, 13 May 2024 13:28:30 -0400
parents 6aecbb32c587
children
line wrap: on
line source
#!/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 uspsapp
#

source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"

: ${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
        if [[ $eol =~ "Up" ]]
        then
           t=(${container//_/ })
           service=${t[1]}
           if [[ $service == $SERVICE ]]
           then
             echo -e "\n$project: Updating $service"
             docker-compose up -d $service
           fi
        fi
      fi
   done < <(docker-compose ps)

done

cd $ORIGINALDIR