changeset 191:fea886ba7279

DEP-12: add source for .functions.sh to all scripts using compose
author smith@nwoca.org
date Wed, 20 Sep 2017 17:56:23 +0100
parents c3587159637f
children 1ca7d299427e dd6d0c580320
files scripts/capture.sh scripts/clearlocks.sh scripts/exec-all-projects.sh scripts/import-usas.sh scripts/import-usps.sh scripts/info.sh scripts/restore-usas.sh scripts/restore-usps.sh scripts/send.sh scripts/updates-apply.sh scripts/updates-cleanup.sh scripts/updates-pull.sh
diffstat 12 files changed, 40 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/capture.sh	Wed Sep 20 17:41:25 2017 +0100
+++ b/scripts/capture.sh	Wed Sep 20 17:56:23 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 17:41:25 2017 +0100
+++ b/scripts/clearlocks.sh	Wed Sep 20 17:56:23 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}"
--- a/scripts/exec-all-projects.sh	Wed Sep 20 17:41:25 2017 +0100
+++ b/scripts/exec-all-projects.sh	Wed Sep 20 17:56:23 2017 +0100
@@ -7,8 +7,27 @@
 # 
 # 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
@@ -23,10 +42,10 @@
    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 17:41:25 2017 +0100
+++ b/scripts/import-usas.sh	Wed Sep 20 17:56:23 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 17:41:25 2017 +0100
+++ b/scripts/import-usps.sh	Wed Sep 20 17:56:23 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 17:41:25 2017 +0100
+++ b/scripts/info.sh	Wed Sep 20 17:56:23 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 17:41:25 2017 +0100
+++ b/scripts/restore-usas.sh	Wed Sep 20 17:56:23 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 17:41:25 2017 +0100
+++ b/scripts/restore-usps.sh	Wed Sep 20 17:56:23 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 17:41:25 2017 +0100
+++ b/scripts/send.sh	Wed Sep 20 17:56:23 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 17:41:25 2017 +0100
+++ b/scripts/updates-apply.sh	Wed Sep 20 17:56:23 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 17:41:25 2017 +0100
+++ b/scripts/updates-cleanup.sh	Wed Sep 20 17:56:23 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 17:41:25 2017 +0100
+++ b/scripts/updates-pull.sh	Wed Sep 20 17:56:23 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