From 6b404c27ffbe8003eca363a07b4a4071a0773426 Mon Sep 17 00:00:00 2001 From: Conrad Lara - KG6JEI Date: Thu, 2 Jul 2015 19:03:47 -0700 Subject: [PATCH] bugfix: move set eth mac fixup to /etc/init.d/local Not getting much debug information at moment, would like to put this in uci-defaults but with issues that I can't seem to log at moment (and not having serial cable for this device) I'm going with lets put it in /etc/init.d/local before nvram and similar gets set. ref AREDN->ticket:115 --- files/etc/init.d/local | 46 +++++++++++++++++++ files/etc/uci-defaults/99_setup_aredn_include | 46 ------------------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/files/etc/init.d/local b/files/etc/init.d/local index 39421c03..36166803 100755 --- a/files/etc/init.d/local +++ b/files/etc/init.d/local @@ -4,6 +4,52 @@ START=99 boot() { + # Deal with lan and wifi having same mac address (common on TP-Link) + if [ ! -f /etc/aredn_include/ethmacfixup ] + then + mkdir -p /etc/aredn_include + touch /etc/aredn_include/ethmacfixup + local lanintf=`uci -q get 'network.lan.ifname'` + local wifiintf="wlan0" + local lanmac=`ifconfig $lanintf | grep -o -E '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}'` + local wifimac=`ifconfig $wifiintf | grep -o -E '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}'` + + if [ "$lanmac" = "$wifimac" ] + then + local wifimacdigit=`echo $wifimac | awk 'BEGIN { FS = ":" } ;{print $4}'` + local newmac="00:00:00:00:00:00" + if [ "$wifimacdigit" = "FF" ] + then + newmac=`echo "$wifimac" | awk 'BEGIN { FS = ":" } ;{print $1":"$2":"$3":00:"$5":"$6}'` + else + local wifimacdigitplusone + wifimacdigitplusone=`printf "%02X\n" $((0x$wifimacdigit + 1))` + newmac=`echo "$wifimac:$wifimacdigitplusone" | awk 'BEGIN { FS = ":" } ;{print $1":"$2":"$3":"$7":"$5":"$6}'` + fi + case $lanintf in + *.*) + echo "" > /etc/aredn_include/ethmacfixup + echo "config interface 'setethmac'" >> /etc/aredn_include/ethmacfixup + echo -e "\toption\tifname\t'eth0'" >> /etc/aredn_include/ethmacfixup + echo -e "\toption\tproto\t'none'" >> /etc/aredn_include/ethmacfixup + echo -e "\toption\tmacaddr\t$newmac" >> /etc/aredn_include/ethmacfixup + uci set "network.setethmac=interface" + uci set "network.setethmac.ifname=eth0" + uci set "network.setethmac.proto=none" + uci set "network.setethmac.macaddr=$newmac" + ;; + *) + uci -q set "network.lan.macaddr=$newmac" + echo -e "\toption\tmacaddr\t$newmac" > /etc/aredn_include/ethmacfixup + ;; + esac + uci commit + /etc/init.d/network reload + /etc/init.d/network restart + fi + fi + + [ -x /usr/local/bin/bbhn-postupgrade ] && /usr/local/bin/bbhn-postupgrade # setup nvram variables diff --git a/files/etc/uci-defaults/99_setup_aredn_include b/files/etc/uci-defaults/99_setup_aredn_include index 923c355f..b2a89fe2 100755 --- a/files/etc/uci-defaults/99_setup_aredn_include +++ b/files/etc/uci-defaults/99_setup_aredn_include @@ -91,50 +91,4 @@ then fi -# Deal with lan and wifi having same mac address (common on TP-Link) -if [ ! -f /etc/aredn_include/ethmacfixup ] -then - mkdir -p /etc/aredn_include - touch /etc/aredn_include/ethmacfixup - local lanintf=`uci -q get 'network.lan.ifname'` - local wifiintf="wlan0" - local lanmac=`ifconfig $lanintf | grep -o -E '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}'` - local wifimac=`ifconfig $wifiintf | grep -o -E '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}'` - - - if [ "$lanmac" = "$wifimac" ] - then - local wifimacdigit=`echo $wifimac | awk 'BEGIN { FS = ":" } ;{print $4}'` - local newmac="00:00:00:00:00:00" - if [ "$wifimacdigit" = "FF" ] - then - newmac=`echo "$wifimac" | awk 'BEGIN { FS = ":" } ;{print $1":"$2":"$3":00:"$5":"$6}'` - else - local wifimacdigitplusone - wifimacdigitplusone=`printf "%02X\n" $((0x$wifimacdigit + 1))` - newmac=`echo "$wifimac:$wifimacdigitplusone" | awk 'BEGIN { FS = ":" } ;{print $1":"$2":"$3":"$7":"$5":"$6}'` - fi - case $lanintf in - *.*) - echo "" > /etc/aredn_include/ethmacfixup - echo "config interface 'setethmac'" >> /etc/aredn_include/ethmacfixup - echo -e "\toption\tifname\t'eth0'" >> /etc/aredn_include/ethmacfixup - echo -e "\toption\tproto\t'none'" >> /etc/aredn_include/ethmacfixup - echo -e "\toption\tmacaddr\t$newmac" >> /etc/aredn_include/ethmacfixup - uci set "network.setethmac=interface" - uci set "network.setethmac.ifname=eth0" - uci set "network.setethmac.proto=none" - uci set "network.setethmac.macaddr=$newmac" - ;; - *) - uci -q set "network.lan.macaddr=$newmac" - echo -e "\toption\tmacaddr\t$newmac" > /etc/aredn_include/ethmacfixup - ;; - esac - uci commit - /etc/init.d/network reload - /etc/init.d/network restart - fi -fi - exit 0