sonic-buildimage/dockers/docker-fpm-frr/TSC

53 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
function check_not_installed()
{
c=0
config=$(vtysh -c "show run")
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6');
do
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
c=$((c+$?))
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
c=$((c+$?))
done
return $c
}
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' | egrep 'V4|V6');
do
echo "$config" | egrep -q "^route-map $route_map_name permit 20$"
c=$((c+$?))
e=$((e+1))
echo "$config" | egrep -q "^route-map $route_map_name deny 30$"
c=$((c+$?))
e=$((e+1))
done
return $((e-c))
}
echo "Traffic Shift Check:"
check_not_installed
not_installed=$?
check_installed
installed=$?
if [[ $installed -eq 0 ]];
then
echo "System Mode: Normal"
elif [[ $not_installed -eq 0 ]];
then
echo "System Mode: Maintenance"
else
echo "System Mode: Not consistent"
fi
echo