From d6d6c8db89908e56c324df31ce0388c4bc5be9c8 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Fri, 28 Apr 2017 19:46:18 +0000 Subject: [PATCH 1/2] [baseos] Avoid disconnecting mgmt when recfg interfaces --- files/image_config/interfaces/interfaces-config.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/files/image_config/interfaces/interfaces-config.sh b/files/image_config/interfaces/interfaces-config.sh index 3e2f852c1263..02b867f7eb3b 100755 --- a/files/image_config/interfaces/interfaces-config.sh +++ b/files/image_config/interfaces/interfaces-config.sh @@ -1,5 +1,11 @@ #!/bin/bash +ifdown -a -X eth0 sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/interfaces.j2 >/etc/network/interfaces -service networking restart -ifdown lo && ifup lo +ifup -a -X eth0 + +NEW_MGMT_IP=`sonic-cfggen -m /etc/sonic/minigraph.xml -v 'minigraph_mgmt_interface["addr"]'` +NEW_MGMT_MASK=`sonic-cfggen -m /etc/sonic/minigraph.xml -v 'minigraph_mgmt_interface["mask"]'` + +ifconfig eth0 $NEW_MGMT_IP netmask $NEW_MGMT_MASK + From 74c15bad06f571dd2e58ff5976e9dce888844a8f Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Fri, 2 Jun 2017 02:04:38 +0000 Subject: [PATCH 2/2] Kill dhclient after interfaces-config --- files/image_config/interfaces/interfaces-config.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/files/image_config/interfaces/interfaces-config.sh b/files/image_config/interfaces/interfaces-config.sh index 02b867f7eb3b..f966e82e8030 100755 --- a/files/image_config/interfaces/interfaces-config.sh +++ b/files/image_config/interfaces/interfaces-config.sh @@ -8,4 +8,5 @@ NEW_MGMT_IP=`sonic-cfggen -m /etc/sonic/minigraph.xml -v 'minigraph_mgmt_interf NEW_MGMT_MASK=`sonic-cfggen -m /etc/sonic/minigraph.xml -v 'minigraph_mgmt_interface["mask"]'` ifconfig eth0 $NEW_MGMT_IP netmask $NEW_MGMT_MASK +[ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid