sonic-buildimage/dockers/docker-lldp-sv2/reconfigure.sh
Shuotian Cheng fd34d907ff [lldp]: Get all interfaces from the database (#1069)
The previous implementation only supports EthernetX while X
varies from 0 - 124. Remove such hard coded logics and use
the information from the database instead.

Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
2017-10-23 19:53:10 -07:00

53 lines
911 B
Bash
Executable File

#!/bin/bash
set -e
# TODO: Listen to state database when it is ready
interfaces=$(sonic-cfggen -d -v "PORT.keys() | join(' ')")
function wait_until_if_exists
{
if=$1
while [ ! -L /sys/class/net/"$if" ] ;
do
sleep 1
done
echo interface "$if" is created
}
function wait_until_if_not_exists
{
if=$1
while [ -L /sys/class/net/"$if" ] ;
do
sleep 1
done
echo interface "$if" is destroyed
}
while /bin/true ;
do
# wait until all interfaces are created
echo Wait until all interfaces are created
for i in $interfaces
do
wait_until_if_exists $i
done
echo Wait 10 seconds while lldpd finds new interfaces
sleep 10
# apply lldpd configuration
echo Apply lldpd configuration
lldpcli -c /etc/lldpd.conf
# wait until all interfaces are destroyed
echo Wait until all ifaces are destroyed
for i in $interfaces
do
wait_until_if_not_exists $i
done
done