[installer] Copy old config files rather than only minigraph (#730)
This commit is contained in:
parent
dd104e1b52
commit
95906a6490
@ -1,55 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
usage(){
|
||||
echo "Usage: $0 <shutdown|startup> <neighbor_ip>"
|
||||
exit 255
|
||||
}
|
||||
|
||||
[[ $# -ne 2 ]] && usage
|
||||
|
||||
COMMAND=$1
|
||||
NEIGHBOR_IP=$2
|
||||
|
||||
if [ "$COMMAND" == "shutdown" ]; then
|
||||
CMD_PREFIX=""
|
||||
elif [ "$COMMAND" == "startup" ]; then
|
||||
CMD_PREFIX="no"
|
||||
else
|
||||
usage
|
||||
fi
|
||||
|
||||
ASN=`vtysh -c "show ip bgp summary" | sed -n "s/.*AS number \([0-9]\+\).*/\1/p"`
|
||||
if [ -z "$ASN" ]; then
|
||||
exit 255
|
||||
fi
|
||||
|
||||
[ -f /etc/sonic/bgp_admin.yml ] || echo "bgp_admin_state:" > /etc/sonic/bgp_admin.yml
|
||||
|
||||
# Operate on all ipv4 neighbors when "neighbor_ip" = 0.0.0.0
|
||||
if [ "$NEIGHBOR_IP" == "0.0.0.0" ] ; then
|
||||
for NEIGHBOR in `vtysh -c "show run" | grep nei | grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | sort | uniq`; do
|
||||
vtysh -c "configure terminal" -c "router bgp $ASN" -c "$CMD_PREFIX neighbor $NEIGHBOR shutdown"
|
||||
|
||||
# Save admin state in config file
|
||||
sed -i "/^\s*$NEIGHBOR:/d" /etc/sonic/bgp_admin.yml
|
||||
if [ "$COMMAND" == "startup" ]; then
|
||||
echo " $NEIGHBOR: on" >> /etc/sonic/bgp_admin.yml
|
||||
else
|
||||
echo " $NEIGHBOR: off" >> /etc/sonic/bgp_admin.yml
|
||||
fi
|
||||
done
|
||||
|
||||
else
|
||||
# Examine bgp neighbor exists first
|
||||
vtysh -c "show ip bgp neighbor $NEIGHBOR_IP" | grep -q "BGP neighbor is"
|
||||
|
||||
vtysh -c "configure terminal" -c "router bgp $ASN" -c "$CMD_PREFIX neighbor $NEIGHBOR_IP shutdown"
|
||||
|
||||
# Save admin state in config file
|
||||
sed -i "/^\s*$NEIGHBOR_IP:/d" /etc/sonic/bgp_admin.yml
|
||||
if [ "$COMMAND" == "startup" ]; then
|
||||
echo " $NEIGHBOR_IP: on" >> /etc/sonic/bgp_admin.yml
|
||||
else
|
||||
echo " $NEIGHBOR_IP: off" >> /etc/sonic/bgp_admin.yml
|
||||
fi
|
||||
fi
|
@ -29,8 +29,11 @@ if [ -f /host/image-$sonic_version/platform/firsttime ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Try to take minigraph saved during installation
|
||||
if [ -f /host/minigraph.xml ]; then
|
||||
# Try to take old configuration saved during installation
|
||||
if [ -d /host/old_config ]; then
|
||||
rm -f /host/old_config/sonic_version.yml
|
||||
mv -f /host/old_config/* /etc/sonic/
|
||||
elif [ -f /host/minigraph.xml ]; then
|
||||
mv /host/minigraph.xml /etc/sonic/
|
||||
else
|
||||
cp /usr/share/sonic/device/$platform/minigraph.xml /etc/sonic/
|
||||
|
@ -11,4 +11,3 @@ $(DOCKER_FPM_QUAGGA)_RUN_OPT += --net=host --privileged -t
|
||||
$(DOCKER_FPM_QUAGGA)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
|
||||
|
||||
$(DOCKER_FPM_QUAGGA)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh
|
||||
$(DOCKER_FPM_QUAGGA)_BASE_IMAGE_FILES += bgp_neighbor:/usr/bin/bgp_neighbor
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit c1b48a6a28f9897ebfebf9989b5cb4a472cf1967
|
||||
Subproject commit 0ad52804301903664dfe8f84ef1666101c950cd2
|
Loading…
Reference in New Issue
Block a user