2019-07-26 16:31:56 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
c=0
|
|
|
|
config=$(vtysh -c "show run")
|
|
|
|
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 permit 2"
|
2019-11-06 18:07:28 -06:00
|
|
|
c=$((c+$?))
|
2019-07-26 16:31:56 -05:00
|
|
|
echo "$config" | grep -q "route-map TO_BGP_PEER_V4 deny 3"
|
2019-11-06 18:07:28 -06:00
|
|
|
c=$((c+$?))
|
2019-07-26 16:31:56 -05:00
|
|
|
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 permit 2"
|
2019-11-06 18:07:28 -06:00
|
|
|
c=$((c+$?))
|
2019-07-26 16:31:56 -05:00
|
|
|
echo "$config" | grep -q "route-map TO_BGP_PEER_V6 deny 3"
|
2019-11-06 18:07:28 -06:00
|
|
|
c=$((c+$?))
|
2019-07-26 16:31:56 -05:00
|
|
|
|
|
|
|
if [[ $c -eq 4 ]];
|
|
|
|
then
|
2019-11-06 18:07:28 -06:00
|
|
|
TSA_FILE=$(mktemp)
|
|
|
|
sonic-cfggen -d -y /etc/sonic/constants.yml -t /usr/share/sonic/templates/bgpd.tsa.isolate.conf.j2 > "$TSA_FILE"
|
|
|
|
vtysh -f "$TSA_FILE"
|
|
|
|
rm -f "$TSA_FILE"
|
2019-07-26 16:31:56 -05:00
|
|
|
echo "System Mode: Normal -> Maintenance"
|
|
|
|
else
|
|
|
|
echo "System is already in Maintenance mode"
|
|
|
|
fi
|