firmware/bsp/dir300/root_file_system/etc/rc.local
Tim Niemeyer 192dd3765c Change BATMAN ethernet ports
BATMAN couldn't handle devices with the same MAC, so this uses the internal
switch to bridge the ports. It also changes the MAC to a localy unique
address.

Signed-off-by: Tim Niemeyer <tim.niemeyer@mastersword.de>
2013-03-30 00:10:52 +01:00

52 lines
1.5 KiB
Text
Executable file

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
# todo: all devices or only dir300 ?
if uci get network.mesh.macaddr
then
echo "MAC is set already"
else
BRMAC=$(awk '{ tolower($0); print }' /sys/class/net/br-mesh/address)
WLMAC=$(awk '{ tolower($0); print }' /sys/class/net/wlan0/address)
ETMAC=$(awk '{ tolower($0); print }' /sys/class/net/eth0/address)
if [ "$WLMAC" != "" ] && [ "$BRMAC" != "" ] && [ "$BRMAC" = "$ETMAC" ]; then
if [[ "$BRMAC" != "$WLMAC" ]]; then
echo "Fixing wrong MAC on br-mesh"
uci set network.mesh.macaddr=$WLMAC
uci commit
ifconfig br-mesh hw ether $WLMAC
ifconfig br-mesh down
ifconfig br-mesh up
#wait before reboot to generate tinc certificates and to be able
#to login over ssh bevore reboot in case of errors
fi
fi
fi
if uci get network.ethmesh.macaddr
then
echo "MAC for ETH-BATMAN is set already"
else
echo "Fixing MAC on eth0.3 (ethmesh)"
NEW=$(awk -F: '{ printf("%02x:%02x:%02x:%02x:%02x:%02x\n", ("0x"$1)+2, "0x"$2, "0x"$3, "0x"$4, "0x"$5, "0x"$6 ) }' /sys/class/net/eth0/address)
uci set network.ethmesh.macaddr=$NEW
uci commit
ifconfig eth0.3 hw ether $NEW
ifconfig eth0.3 down
ifconfig eth0.3 up
fi
batctl if add wlan0-1
batctl if add eth0.3
# Starting NTP-Client Daemon
ntpd -p "fe80::201:2ff:fe03:405%br-mesh"
#. /etc/firewall.user
#busybox-httpd for crawldata
mkdir /tmp/crawldata
httpd -h /tmp/crawldata
exit 0