-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathupgrade.sh
More file actions
executable file
·27 lines (23 loc) · 791 Bytes
/
Copy pathupgrade.sh
File metadata and controls
executable file
·27 lines (23 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
# for docker stack
# FIXME. both updated(pdnsd and dnscrypt-proxy-2) if one config changed.
service_name="$1"
if [[ -z $service_name ]]; then
echo "usage: $0 service_name"
exit 1
fi
config_name=$(docker service inspect --format '{{(index .Spec.TaskTemplate.ContainerSpec.Configs 0).ConfigName }}' $service_name)
if [[ -z "$config_name" ]]; then
echo "get service $service_name first config failed"
exit 1
fi
now_version=${config_name##*-}
new_version=$((now_version+1))
echo "version, now=$now_version, new=$new_version"
name=$(echo ${config_name%%-*} | tr 'a-z' 'A-Z')
eval "${name}_CONFIG_VERSION=$new_version"
export ${name}_CONFIG_VERSION
docker stack deploy -c ./dnscrypt.yml dnscrypt
if [[ $? -eq 0 ]]; then
docker config rm $config_name
fi