2019-05-09 01:00:49 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
mkdir -p /etc/frr
|
2020-08-17 17:47:42 -05:00
|
|
|
mkdir -p /etc/supervisor/conf.d
|
|
|
|
|
|
|
|
CFGGEN_PARAMS=" \
|
|
|
|
-d \
|
|
|
|
-y /etc/sonic/constants.yml \
|
|
|
|
-t /usr/share/sonic/templates/supervisord/frr_vars.j2 \
|
|
|
|
-t /usr/share/sonic/templates/supervisord/supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf \
|
|
|
|
-t /usr/share/sonic/templates/bgpd/bgpd.conf.j2,/etc/frr/bgpd.conf \
|
|
|
|
-t /usr/share/sonic/templates/zebra/zebra.conf.j2,/etc/frr/zebra.conf \
|
|
|
|
-t /usr/share/sonic/templates/staticd/staticd.conf.j2,/etc/frr/staticd.conf \
|
|
|
|
-t /usr/share/sonic/templates/frr.conf.j2,/etc/frr/frr.conf \
|
|
|
|
-t /usr/share/sonic/templates/isolate.j2,/usr/sbin/bgp-isolate \
|
|
|
|
-t /usr/share/sonic/templates/unisolate.j2,/usr/sbin/bgp-unisolate \
|
|
|
|
"
|
|
|
|
CONFIG_TYPE=$(sonic-cfggen $CFGGEN_PARAMS)
|
2019-05-09 01:00:49 -05:00
|
|
|
|
2020-10-06 00:54:47 -05:00
|
|
|
update_default_gw()
|
|
|
|
{
|
|
|
|
IP_VER=${1}
|
2020-06-29 13:38:46 -05:00
|
|
|
# FRR is not running in host namespace so we need to delete
|
|
|
|
# default gw kernel route added by docker network via eth0 and add it back
|
|
|
|
# with higher administrative distance so that default route learnt
|
|
|
|
# by FRR becomes best route if/when available
|
2020-10-06 00:54:47 -05:00
|
|
|
GATEWAY_IP=$(ip -${IP_VER} route show default dev eth0 | awk '{print $3}')
|
2020-06-29 13:38:46 -05:00
|
|
|
#Check if docker default route is there
|
|
|
|
if [[ ! -z "$GATEWAY_IP" ]]; then
|
2020-10-06 00:54:47 -05:00
|
|
|
ip -${IP_VER} route del default dev eth0
|
2020-06-29 13:38:46 -05:00
|
|
|
#Make sure route is deleted
|
2020-10-06 00:54:47 -05:00
|
|
|
CHECK_GATEWAY_IP=$(ip -${IP_VER} route show default dev eth0 | awk '{print $3}')
|
2020-06-29 13:38:46 -05:00
|
|
|
if [[ -z "$CHECK_GATEWAY_IP" ]]; then
|
|
|
|
# Ref: http://docs.frrouting.org/en/latest/zebra.html#zebra-vrf
|
|
|
|
# Zebra does treat Kernel routes as special case for the purposes of Admin Distance. \
|
|
|
|
# Upon learning about a route that is not originated by FRR we read the metric value as a uint32_t.
|
|
|
|
# The top byte of the value is interpreted as the Administrative Distance and
|
|
|
|
# the low three bytes are read in as the metric.
|
|
|
|
# so here we are programming administrative distance of 210 (210 << 24) > 200 (for routes learnt via IBGP)
|
2020-10-06 00:54:47 -05:00
|
|
|
ip -${IP_VER} route add default via $GATEWAY_IP dev eth0 metric 3523215360
|
2020-06-29 13:38:46 -05:00
|
|
|
fi
|
|
|
|
fi
|
2020-10-06 00:54:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if [[ ! -z "$NAMESPACE_ID" ]]; then
|
|
|
|
update_default_gw 4
|
|
|
|
update_default_gw 6
|
2020-06-29 13:38:46 -05:00
|
|
|
fi
|
|
|
|
|
2019-05-09 01:00:49 -05:00
|
|
|
if [ -z "$CONFIG_TYPE" ] || [ "$CONFIG_TYPE" == "separated" ]; then
|
2019-06-12 03:09:31 -05:00
|
|
|
echo "no service integrated-vtysh-config" > /etc/frr/vtysh.conf
|
2019-06-01 11:33:52 -05:00
|
|
|
rm -f /etc/frr/frr.conf
|
2019-05-09 01:00:49 -05:00
|
|
|
elif [ "$CONFIG_TYPE" == "unified" ]; then
|
|
|
|
echo "service integrated-vtysh-config" > /etc/frr/vtysh.conf
|
2019-08-16 16:29:42 -05:00
|
|
|
rm -f /etc/frr/bgpd.conf /etc/frr/zebra.conf /etc/frr/staticd.conf
|
2019-05-09 01:00:49 -05:00
|
|
|
fi
|
|
|
|
|
2019-10-15 13:45:09 -05:00
|
|
|
chown -R frr:frr /etc/frr/
|
|
|
|
|
2019-05-09 01:00:49 -05:00
|
|
|
chown root:root /usr/sbin/bgp-isolate
|
|
|
|
chmod 0755 /usr/sbin/bgp-isolate
|
|
|
|
|
|
|
|
chown root:root /usr/sbin/bgp-unisolate
|
|
|
|
chmod 0755 /usr/sbin/bgp-unisolate
|
|
|
|
|
|
|
|
mkdir -p /var/sonic
|
|
|
|
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status
|
2016-07-26 14:01:58 -05:00
|
|
|
|
2017-03-29 20:07:25 -05:00
|
|
|
rm -f /var/run/rsyslogd.pid
|
2019-05-09 01:00:49 -05:00
|
|
|
|
|
|
|
supervisorctl start rsyslogd
|
|
|
|
|
2019-11-13 16:10:11 -06:00
|
|
|
# start eoiu pulling, only if configured so
|
Fix the below frr start.sh jija2 exception in 201911 image syslog: (#4958)
File "/usr/local/bin/sonic-cfggen", line 380, in <module>
main()
File "/usr/local/bin/sonic-cfggen", line 354, in main
print(template.render(data))
File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 471, in getattr
return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'WARM_RESTART' is undefined
Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
2020-07-14 10:02:32 -05:00
|
|
|
if [[ $(sonic-cfggen -d -v 'WARM_RESTART.bgp.bgp_eoiu if WARM_RESTART and WARM_RESTART.bgp and WARM_RESTART.bgp.bgp_eoiu') == 'true' ]]; then
|
2019-11-13 18:41:41 -06:00
|
|
|
supervisorctl start bgp_eoiu_marker
|
2019-11-13 16:10:11 -06:00
|
|
|
fi
|
|
|
|
|
2019-05-09 01:00:49 -05:00
|
|
|
# Start Quagga processes
|
|
|
|
supervisorctl start zebra
|
2019-05-16 12:59:12 -05:00
|
|
|
supervisorctl start staticd
|
2019-05-09 01:00:49 -05:00
|
|
|
supervisorctl start bgpd
|
|
|
|
|
2019-06-01 11:33:52 -05:00
|
|
|
if [ "$CONFIG_TYPE" == "unified" ]; then
|
2019-05-09 01:00:49 -05:00
|
|
|
supervisorctl start vtysh_b
|
|
|
|
fi
|
|
|
|
|
|
|
|
supervisorctl start fpmsyncd
|
2019-10-24 09:35:14 -05:00
|
|
|
|
|
|
|
supervisorctl start bgpcfgd
|
2020-09-22 14:13:37 -05:00
|
|
|
supervisorctl start bgpmon
|