docker-keepalived/image/service/keepalived/finish.sh

27 lines
689 B
Bash
Raw Permalink Normal View History

2016-08-27 08:37:00 +00:00
#!/bin/bash -e
# set -x (bash debug) if log level is trace
# https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/log-helper
log-helper level eq trace && set -x
# try to delete virtual ips from interface
for vip in $(complex-bash-env iterate KEEPALIVED_VIRTUAL_IPS)
do
2017-04-02 17:53:16 +00:00
IP=$(echo ${!vip} | awk '{print $1}')
2017-04-02 14:03:27 +00:00
IP_INFO=$(ip addr list | grep ${IP}) || continue
2017-04-02 17:53:16 +00:00
IP_V6=$(echo "${IP_INFO}" | grep "inet6") || true
2017-04-02 12:25:09 +00:00
# ipv4
if [ -z "${IP_V6}" ]; then
IP_INTERFACE=$(echo "${IP_INFO}" | awk '{print $5}')
# ipv6
else
2017-04-02 14:03:27 +00:00
echo "skipping address: ${IP} - ipv6 not supported yet :("
2017-04-02 12:25:09 +00:00
continue
fi
2017-04-02 14:03:27 +00:00
ip addr del ${IP} dev ${IP_INTERFACE} || true
2016-08-27 08:37:00 +00:00
done
exit 0