just fix the mac on br-mesh when it's needed (better check)

Signed-off-by: Tim Niemeyer <tim.niemeyer@mastersword.de>
This commit is contained in:
Tim Niemeyer 2012-09-28 20:11:38 +02:00
parent 37df7e20c3
commit 0dca09fee9
1 changed files with 22 additions and 17 deletions

View File

@ -15,24 +15,29 @@ toLower() {
} }
# todo: all devices or only dir300 ? # todo: all devices or only dir300 ?
BRMAC=`ip link | grep br-mesh -A1 | grep link | awk '{ print $2 }'` if uci get network.mesh.macaddr
BRMAC=`toLower $BRMAC` then
WLMAC=`ip link | grep wlan0 -A1 | grep link | awk '{ print $2 }'` echo "MAC is set already"
WLMAC=`toLower $WLMAC` else
ETMAC=`ip link | grep eth0 -A1 | grep link | awk '{ print $2 }'` BRMAC=`ip link | grep br-mesh -A1 | grep link | awk '{ print $2 }'`
ETMAC=`toLower $ETMAC` BRMAC=`toLower $BRMAC`
WLMAC=`ip link | grep wlan0 -A1 | grep link | awk '{ print $2 }'`
WLMAC=`toLower $WLMAC`
ETMAC=`ip link | grep eth0 -A1 | grep link | awk '{ print $2 }'`
ETMAC=`toLower $ETMAC`
if [ "$WLMAC" != "" ] && [ "$BRMAC" != "" ] && [ "$BRMAC" = "$ETMAC" ]; then if [ "$WLMAC" != "" ] && [ "$BRMAC" != "" ] && [ "$BRMAC" = "$ETMAC" ]; then
if [[ "$BRMAC" != "$WLMAC" ]]; then if [[ "$BRMAC" != "$WLMAC" ]]; then
logger -s "Fixing wrong MAC on br-mesh" echo "Fixing wrong MAC on br-mesh"
uci set network.mesh.macaddr=$WLMAC uci set network.mesh.macaddr=$WLMAC
uci commit uci commit
ifconfig br-mesh hw ether $WLMAC ifconfig br-mesh hw ether $WLMAC
ifconfig br-mesh down ifconfig br-mesh down
ifconfig br-mesh up ifconfig br-mesh up
#wait before reboot to generate tinc certificates and to be able #wait before reboot to generate tinc certificates and to be able
#to login over ssh bevore reboot in case of errors #to login over ssh bevore reboot in case of errors
fi fi
fi
fi fi
# Starting NTP-Client Daemon # Starting NTP-Client Daemon