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