diff options
| author | Jenkins <jenkins@review.openstack.org> | 2015-06-24 06:01:40 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2015-06-24 06:01:40 +0000 |
| commit | 54aa5d2fd185ec290b545b7eac3366a320f4488d (patch) | |
| tree | c7212ab56cd9f7181af129f6a1f369abb2061b76 /docker/centos/binary/keepalived/start.sh | |
| parent | 2336ba39d49b9a463ce627b1a8dbc3f3f866252d (diff) | |
| parent | 52f49094356ca70495e3bc606751d55104726881 (diff) | |
| download | kolla-54aa5d2fd185ec290b545b7eac3366a320f4488d.tar.gz kolla-54aa5d2fd185ec290b545b7eac3366a320f4488d.zip | |
Merge "Keepalived container"
Diffstat (limited to 'docker/centos/binary/keepalived/start.sh')
| -rwxr-xr-x | docker/centos/binary/keepalived/start.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/docker/centos/binary/keepalived/start.sh b/docker/centos/binary/keepalived/start.sh new file mode 100755 index 000000000..7f582b218 --- /dev/null +++ b/docker/centos/binary/keepalived/start.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +. /opt/kolla/kolla-common.sh + +check_required_vars KEEPALIVED_HOST_PRIORITIES PUBLIC_IP PUBLIC_INTERFACE + +MY_HOSTNAME=`hostname` + +# here we unpack KEEPALIVED_HOST_PRIORITIES hostname:priority pairs and match +# them with current hostname, if it's there +for i in ${KEEPALIVED_HOST_PRIORITIES//,/ }; do + HOST_PRIORITY=(${i//:/ }) + if [ "$MY_HOSTNAME" == "${HOST_PRIORITY[0]}" ]; then + KEEPALIVED_PRIORITY=${HOST_PRIORITY[1]} + fi +done + +if [ -z "$KEEPALIVED_PRIORITY" ]; then + echo "ERROR: missing hostname in KEEPALIVED_HOST_PRIORITIES: $MY_HOSTNAME" >&2 + exit 1 +fi + +sed -i ' + s|@PUBLIC_INTERFACE@|'$PUBLIC_INTERFACE'|g + s|@PUBLIC_IP@|'$PUBLIC_IP'|g + s|@KEEPALIVED_PRIORITY@|'$KEEPALIVED_PRIORITY'|g +' /etc/keepalived/keepalived.conf + +exec /usr/sbin/keepalived -nld -p /run/keepalived.pid |
