You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1 KiB

7 years ago
#!/bin/bash
limit=''
4 years ago
force=''
7 years ago
while test $# -gt 0; do
case "$1" in
(-h|--help) cat <<EOF
$0 [OPTIONS] FILES…
7 years ago
OPTIONS
-h, --help show this help
-s, --limit service limit update to given service
4 years ago
-f, --force force update
7 years ago
FILES…
7 years ago
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.
7 years ago
DESCRIPTION
Updates the docker images of all services in the given stacks.
7 years ago
EOF
exit;;
(-l|--limit) shift; limit=$1;;
4 years ago
(-f|--force) force='--force';;
7 years ago
(*) 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
name=${name##*/}
7 years ago
echo "upgrading ${name}"
IFS="
"
for param in $(sed -n '/^ *\([^:]\+\): *$/{s,,'"${name}"'_\1,;h};/^ *image: */{s///;G;s/\n/ /p}' $file); do
7 years ago
IFS=" "
if [ -z "$limit" ] || [[ "${param}" =~ " ${name}_${limit}" ]]; then
echo "....update $param: docker service update --image $param"
4 years ago
docker service update $force --image $param
7 years ago
fi
done
done