changeset 195:26bb64873bbe production v1.3.0

flow: Merged <release> 'v1.3.0' to <master> ('production').
author smith@nwoca.org
date Thu, 21 Sep 2017 17:14:46 +0100
parents 26892906f365 (current diff) 0f1bb8893cc6 (diff)
children d17fc18e3981
files
diffstat 15 files changed, 81 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/.functions.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/.functions.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -11,6 +11,11 @@
    export SSDT_HOME=$(dirname $SSDT_SCRIPTS)
 fi
 
+if [ "$(which docker-compose)" ==  "" ]
+then
+   PATH="${PATH}:/usr/local/bin"
+fi
+
 export SSDT_DOCKER_VERSION=$(docker version --format '{{.Server.Version}}')
 
 # deletes psql data from specified service
--- a/scripts/backup-container.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/backup-container.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -9,6 +9,10 @@
 #
 container=${1?Must provide container name to backup}
 
+projectDir=${2:-$PWD}
+
+cd $projectDir
+
 source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
 
 set -o pipefail
@@ -23,7 +27,7 @@
 fi
 
 echo "starting backup of $container for $project"
-docker-compose exec $container sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container ; (exit $?) " > ${backupFile}
+docker-compose exec -T $container sh -c "gosu postgres pg_dump -Cc --if-exists --dbname=$container ; (exit $?) " > ${backupFile}
 
 if [[ $( grep --count "CREATE TABLE" ${backupFile} ) -lt 200 || $( grep --count "PostgreSQL database dump complete" ${backupFile} ) -eq 0 ]]; then
    echo "ERROR: backup verification FAILED"
--- a/scripts/backup-usps.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/backup-usps.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -2,5 +2,5 @@
 
 source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
 
-${SSDT_SCRIPTS}/backup-container.sh uspsdb
+${SSDT_SCRIPTS}/backup-container.sh uspsdb ${1}
 
--- a/scripts/capture.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/capture.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -1,4 +1,6 @@
 #!/bin/bash
 # current logs to standard out from container (all containers by default) in current project
+source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
+
 docker-compose logs --no-color $1
 
--- a/scripts/clearlocks.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/clearlocks.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -1,5 +1,6 @@
 #!/bin/bash
-source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh"
+source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
+
 if [ -z "$1" ]
 then
   echo "Usage: `basename $0` {db service}"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/exec-all-projects.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -0,0 +1,51 @@
+#!/bin/bash
+# Scans for docker projects in specified parent path and
+# executes the specified command.
+#
+# The first parameter specifices theparent directory to search for 
+# docker-compose.yml # files must be specified.  #
+# 
+# the second paramter specifies the command to execute against each
+# compose project.
+#
+# examples:
+#
+#   /ssdt/scripts/exec-all-projects.sh /data/pilot docker-compose ps
+# 
+#     executes "docker-compose ps" against all projects under /data/pilot
+#
+#   /ssdt/scripts/exec-all-projects.sh /data/pilot /ssdt/ /ssdt/scripts/backup-usas.sh
+#
+#     runs backup-usas.sh script against all projects under /data/pilot
+#
+#   /ssdt/scripts/exec-all-projects.sh /data/pilot "/ssdt/scripts/capture.sh | /ssdt/scripts/send.sh -"
+#
+#       captures the log files from all containers and sends one long file per project 
+#       to the SSDT support server.
+#
+#
+##
+
+source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
+
+: ${1?"Usage: {parent path} [command]"}
+
+ORIGINALDIR=$PWD
+PARENTDIR=$1
+
+shift
+COMMAND=$@
+
+for f in $(find $PARENTDIR -name docker-compose.yml)
+do
+   projectdir=`dirname $f`
+   project=`basename $projectdir`
+   cd $projectdir
+   echo -e "----\n$executing $COMMAND on $project \n----"      
+
+   bash -c "${COMMAND}"
+   echo ""
+
+done
+
+cd $ORIGINALDIR
--- a/scripts/import-usas.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/import-usas.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh"
+source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
 
 docker-compose stop usasapp usasdb
 resetDbVolume usasdb
--- a/scripts/import-usps.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/import-usps.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh"
+source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
 
 docker-compose stop uspsapp uspsdb
 resetDbVolume uspsdb
--- a/scripts/info.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/info.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -1,5 +1,6 @@
 #!/bin/bash
- source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh"
+source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
+
 echo $BASH_VERSION
 docker version
 docker-compose version
--- a/scripts/restore-usas.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/restore-usas.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -1,4 +1,5 @@
 #!/bin/bash
+
 if [ -z "$1" ]
 then
   echo "Usage: `basename $0` {backup file to restore}"
@@ -6,6 +7,8 @@
   exit $E_NOARGS
 fi
 
+source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
+
 docker-compose stop usasapp
 docker-compose restart usasdb
 docker-compose run --rm usasdb sh -c \
--- a/scripts/restore-usps.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/restore-usps.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -5,6 +5,7 @@
   echo  " filename must relative to the container's file system. (e.g. /backup/filename)"
   exit $E_NOARGS
 fi
+source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
 
 docker-compose stop uspsapp
 docker-compose restart uspsdb
--- a/scripts/send.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/send.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -5,7 +5,7 @@
 #     capture.sh | send.sh -   # sends log files to ssdt server for the current project
 #     send.sh docker-compose.yml  # sends the compose file
 #
-source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh"
+source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
 
 file=${1?"Usage: $0 filename [name]\n specify the filename relative to the current directory or - for stdin.\noptionally specify a short name (default to base directory)"}
 if [ "$file" != "-" ]
--- a/scripts/updates-apply.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/updates-apply.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -14,6 +14,9 @@
 #   /ssdt/apply-updates.sh /data/preview
 #   /ssdt/apply-updates.sh /data/preview usps
 #
+
+source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
+
 : ${1?"Usage: {parent path} [service]"}
 SERVICE=${2:-*app}
 
--- a/scripts/updates-cleanup.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/updates-cleanup.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -2,6 +2,7 @@
 #
 # Safely removes obsolete images from previous SSDT versions.
 #
+source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
 
 docker images --filter "label=io.ssdt.app" --filter "dangling=true" -q | xargs docker rmi
 
--- a/scripts/updates-pull.sh	Wed Sep 20 16:19:18 2017 +0100
+++ b/scripts/updates-pull.sh	Thu Sep 21 17:14:46 2017 +0100
@@ -12,6 +12,8 @@
 #
 # Note: if filter is provided, the first argument is ignored. A complete filter must be supplied.
 #
+source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
+
 APP=${1:+=$1}
 FILTER=${2:-label=io.ssdt.app$APP}
 while read -a line