1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-15 04:32:11 +00:00
iiab/roles/network/templates/gateway/check-LAN

62 lines
2.1 KiB
Text
Raw Normal View History

2017-05-27 18:09:50 +00:00
#!/bin/bash
run_detect(){
logger "check-LAN: running reconfig"
cd /opt/schoolserver/iiab
/opt/schoolserver/iiab/runtags network > /dev/null
2017-05-27 18:09:50 +00:00
logger "check-LAN: completed reconfig"
exit 0
}
exit_clean(){
logger "check-LAN: completed - nothing to do"
exit 0
}
logger "check-LAN: startup"
if [ -f /etc/sysconfig/xs_lan_device ]; then
LAN_DEVICE=`cat /etc/sysconfig/xs_lan_device`
if [ "x$LAN_DEVICE" = "x" ]; then
logger "check-LAN: no lan expected"
exit_clean
else
if [ "$LAN_DEVICE" = "br0" ]; then
SLAVES=`egrep -rn BRIDGE=br0 /etc/sysconfig/network-scripts/ifcfg-* \
| gawk -F'[-:]' '{print $3}'`
SLAVE_COUNT=`egrep -rn BRIDGE=br0 /etc/sysconfig/network-scripts/ifcfg-* \
| wc | awk '{print $1}'`
logger "check-LAN: looking for $SLAVE_COUNT slaves"
while [ "$SLAVE_COUNT" > 1 ]; do
TEST_SLAVE=`brctl show | tail -n $[ $SLAVE_COUNT - 1 ] | awk '{print $1}'`
if [ "x$TEST_SLAVE" = "x" ]; then
logger "check-LAN: blank slave for number $SLAVE_COUNT"
run_detect
else
logger "check-LAN: slave number $SLAVE_COUNT $TEST_SLAVE present"
fi
SLAVE_COUNT="$[ $SLAVE_COUNT - 1 ]"
if [ "$SLAVE_COUNT" = 1 ]; then
TEST_SLAVE=`brctl show | grep br0 | awk '{print $4}'`
if [ "x$TEST_SLAVE" = "x" ]; then
logger "check-LAN: single blank slave for number $SLAVE_COUNT"
run_detect
else
logger "check-LAN: single slave number $SLAVE_COUNT $TEST_SLAVE present"
exit_clean
fi
fi
done
fi
LAN_IF=`ip -o addr | grep 172.18 | awk '{print $2}'`
if [ "$LAN_IF" = "$LAN_DEVICE" ]; then
logger "check-LAN: expected LAN matched $LAN_DEVICE"
exit_clean
fi
fi
else
logger "check-LAN: unconfigured"
exit_clean
fi