2016-10-07 12:41:44 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
TEAMD_CONF_PATH=/etc/teamd
|
|
|
|
|
2017-03-02 17:59:16 -06:00
|
|
|
# Before teamd could automatically add newly created host interfaces into the
|
|
|
|
# LAG, this workaround will be needed. It will remove the obsolete files and
|
|
|
|
# net devices that are failed to be removed in the previous run.
|
2017-02-15 10:54:10 -06:00
|
|
|
function start_app {
|
2017-03-02 17:59:16 -06:00
|
|
|
# Remove *.pid and *.sock files if there are any
|
|
|
|
rm -f /var/run/teamd/*
|
2017-02-15 10:54:10 -06:00
|
|
|
if [ -d $TEAMD_CONF_PATH ]; then
|
|
|
|
for f in $TEAMD_CONF_PATH/*; do
|
2017-03-02 17:59:16 -06:00
|
|
|
# Remove netdevs if there are any
|
|
|
|
intf=`echo $f | awk -F'[/.]' '{print $4}'`
|
|
|
|
ip link del $intf
|
2017-02-15 10:54:10 -06:00
|
|
|
teamd -f $f -d
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
teamsyncd &
|
|
|
|
}
|
|
|
|
|
2016-10-07 12:41:44 -05:00
|
|
|
function clean_up {
|
2017-02-15 10:54:10 -06:00
|
|
|
pkill -9 teamd
|
|
|
|
pkill -9 teamsyncd
|
|
|
|
service rsyslog stop
|
|
|
|
exit
|
2016-10-07 12:41:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
trap clean_up SIGTERM SIGKILL
|
|
|
|
|
|
|
|
service rsyslog start
|
|
|
|
|
2017-02-15 10:54:10 -06:00
|
|
|
# Before teamd could automatically add newly created host interfaces into the
|
|
|
|
# LAG, this workaround will wait until the host interfaces are created and then
|
|
|
|
# the processes will be started.
|
|
|
|
while true; do
|
|
|
|
# Check if front-panel ports are configured
|
|
|
|
result=`echo -en "SELECT 0\nHGETALL PORT_TABLE:ConfigDone" | redis-cli | sed -n 3p`
|
2017-03-02 20:07:43 -06:00
|
|
|
if [ "$result" == "0" ]; then
|
2017-02-15 10:54:10 -06:00
|
|
|
start_app
|
|
|
|
read
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|