From bf1408ca8c5c0aecbe5556345a0853f55c015a89 Mon Sep 17 00:00:00 2001 From: mwaeckerlin Date: Tue, 26 Sep 2017 12:52:39 +0200 Subject: [PATCH] aded scripts --- deploy.sh | 14 ++++++++++++++ update.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100755 deploy.sh create mode 100755 update.sh diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..dc61448 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,14 @@ +#!/bin/bash -e + +for f in $*; do + f=${f%.yaml} + if ! test -e ${f}.yaml; then + echo "ERROR: no file ${f}.yaml" 1>&2 + exit 1 + fi + echo "... deploying $f" + for d in $(sed -n 's/^ *source: *//p' ${f}.yaml); do + test -e $d || mkdir -p $d + done + docker stack deploy --compose-file ${f}.yaml ${f} +done diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..bda654f --- /dev/null +++ b/update.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +limit='' +while test $# -gt 0; do + case "$1" in + (-h|--help) cat <&2 + exit 1 + fi + shift +done + +for f in $*; do + name=${f%.yaml} + file=${name}.yaml + echo "upgrading ${name}" + IFS=" +" + for param in $(sed -n '/^ *\([^:]\+\): *$/{s//'"${name}"'_\1/;h};/^ *image: */{s///;G;s/\n/ /p}' $file); do + IFS=" " + if [ -z "$limit" ] || [[ "${param}" =~ " ${name}_${limit}" ]]; then + echo "....update $param: docker service update -d --image $param" + docker service update -d --image $param + fi + done +done +