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 28 29 30 31 32 33 34 35 36 37
|
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
BGP_AGENT_CONF="/etc/neutron/bgp_dragent.ini"
#PKGOS-INCLUDE#
manage_router_id() {
pkgos_inifile get ${BGP_AGENT_CONF} bgp bgp_router_id
if [ -n "${RET}" ] && [ ! "${RET}" = "NOT_FOUND" ] ; then
db_set neutron-dynamic-routing/router-id "${RET}"
else
DEFROUTE_IF=`awk '{ if ( $2 == "00000000" ) print $1 }' /proc/net/route | head -n 1`
if [ -n "${DEFROUTE_IF}" ] ; then
DEFROUTE_IP=$(LC_ALL=C ip addr show "${DEFROUTE_IF}" | grep inet | head -n 1 | awk '{print $2}' | cut -d/ -f1 | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' || true)
fi
if [ -z "${DEFROUTE_IP}" ] ; then
HOSTNAME_IP=$(hostname -i)
if [ -n "${HOSTNAME_IP}" ] ; then
DEFROUTE_IP=${HOSTNAME_IP}
fi
fi
if [ -n "${DEFROUTE_IP}" ] ; then
db_set neutron-dynamic-routing/router-id ${DEFROUTE_IP}
fi
fi
db_input high neutron-dynamic-routing/router-id || true
db_go
}
# Ask user if he wants db migration
db_input high neutron-dynamic-routing/configure-dynamic-routing || true
manage_router_id
db_go || true
|