diff --git a/image/service/keepalived/finish.sh b/image/service/keepalived/finish.sh new file mode 100755 index 0000000..9d1280a --- /dev/null +++ b/image/service/keepalived/finish.sh @@ -0,0 +1,13 @@ +#!/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 + ip addr del ${vip}/32 dev ${KEEPALIVED_INTERFACE} || true +done + +exit 0 diff --git a/image/service/keepalived/startup.sh b/image/service/keepalived/startup.sh index 51206db..387f969 100755 --- a/image/service/keepalived/startup.sh +++ b/image/service/keepalived/startup.sh @@ -39,6 +39,12 @@ if [ ! -e "$FIRST_START_DONE" ]; then touch $FIRST_START_DONE fi +# try to delete virtual ips from interface +for vip in $(complex-bash-env iterate KEEPALIVED_VIRTUAL_IPS) +do + ip addr del ${vip}/32 dev ${KEEPALIVED_INTERFACE} || true +done + if [ ! -e "/etc/backup-manager.conf" ]; then ln -sf ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf /etc/keepalived/keepalived.conf fi