2016-10-31 14:25:09 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
num_of_interfaces=32
|
|
|
|
if_step=4
|
|
|
|
last_if_idx=$((num_of_interfaces*if_step - if_step))
|
|
|
|
|
|
|
|
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
|
|
|
|
echo Wait until all ifaces are created
|
2016-10-31 14:25:09 -05:00
|
|
|
for i in $(seq 0 $if_step $last_if_idx)
|
|
|
|
do
|
2016-10-31 15:56:45 -05:00
|
|
|
wait_until_if_exists "Ethernet$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
|
|
|
|
echo apply lldpd configuration
|
|
|
|
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
|
2016-10-31 14:25:09 -05:00
|
|
|
for i in $(seq 0 $if_step $last_if_idx)
|
|
|
|
do
|
2016-10-31 15:56:45 -05:00
|
|
|
wait_until_if_not_exists "Ethernet$i"
|
2016-10-31 14:25:09 -05:00
|
|
|
done
|
|
|
|
done
|