2019-07-26 16:31:56 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-04-23 11:42:22 -05:00
|
|
|
function check_installed()
|
|
|
|
{
|
|
|
|
c=0
|
|
|
|
e=0
|
|
|
|
config=$(vtysh -c "show run")
|
|
|
|
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
|
|
|
|
do
|
|
|
|
echo "$config" | grep -q "route-map $route_map_name permit 2"
|
|
|
|
c=$((c+$?))
|
|
|
|
e=$((e+1))
|
|
|
|
echo "$config" | grep -q "route-map $route_map_name deny 3"
|
|
|
|
c=$((c+$?))
|
|
|
|
e=$((e+1))
|
|
|
|
done
|
|
|
|
return $((e-c))
|
|
|
|
}
|
2019-07-26 16:31:56 -05:00
|
|
|
|
2020-04-23 11:42:22 -05:00
|
|
|
check_installed
|
|
|
|
installed=$?
|
|
|
|
if [[ $installed -ne 0 ]];
|
2019-07-26 16:31:56 -05:00
|
|
|
then
|
2019-11-06 18:07:28 -06:00
|
|
|
TSB_FILE=$(mktemp)
|
2020-04-23 11:42:22 -05:00
|
|
|
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
|
|
|
|
do
|
|
|
|
sonic-cfggen -d -a "{\"route_map_name\":\"$route_map_name\"}" -t /usr/share/sonic/templates/bgpd/tsa/bgpd.tsa.unisolate.conf.j2 > "$TSB_FILE"
|
|
|
|
vtysh -f "$TSB_FILE"
|
|
|
|
rm -f "$TSB_FILE"
|
|
|
|
done
|
2019-07-26 16:31:56 -05:00
|
|
|
echo "System Mode: Maintenance -> Normal"
|
|
|
|
else
|
|
|
|
echo "System is already in Normal mode"
|
|
|
|
fi
|