new names and new script

This commit is contained in:
Marc Wäckerlin
2018-01-07 01:26:05 +01:00
parent e004687ce1
commit bc27e9f00a
4 changed files with 136 additions and 0 deletions

49
docker-update Executable file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
limit=''
while test $# -gt 0; do
case "$1" in
(-h|--help) cat <<EOF
$0 [OPTIONS] FILES…
OPTIONS
-h, --help show this help
-s, --limit service limit update to given service
FILES…
List of stack names or yaml files to deploy. There must be yaml
files with the same name. The extension .yaml may be given or not.
DESCRIPTION
Updates the docker images of all services in the given stacks.
EOF
exit;;
(-l|--limit) shift; limit=$1;;
(*) break;;
esac
if test $# -lt 1; then
echo "error: missing argument, try $0 --help" 1>&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