[baseos] Avoid disconnecting mgmt when re-cfg interfaces (#553)

* [baseos] Avoid disconnecting mgmt when recfg interfaces

* Kill dhclient after interfaces-config
This commit is contained in:
Taoyu Li 2017-06-06 17:12:26 -07:00 committed by lguohan
parent 820e7aafd0
commit e74196cd75

View File

@ -1,5 +1,12 @@
#!/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
[ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid