2013-11-14 23:11:16 -07:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
# Copyright (C) 2006 OpenWrt.org
|
|
|
|
|
|
|
|
START=99
|
|
|
|
boot() {
|
2014-11-12 22:25:41 -07:00
|
|
|
|
2015-07-02 20:03:47 -06:00
|
|
|
# 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
|
2018-05-15 20:34:32 -06:00
|
|
|
lanintf=${lanintf%%.*}
|
|
|
|
echo "" > /etc/aredn_include/ethmacfixup
|
|
|
|
echo "config interface 'setethmac'" >> /etc/aredn_include/ethmacfixup
|
|
|
|
echo -e "\toption\tifname\t'$lanintf'" >> /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=$lanintf"
|
|
|
|
uci set "network.setethmac.proto=none"
|
|
|
|
uci set "network.setethmac.macaddr=$newmac"
|
|
|
|
uci commit
|
2015-07-02 20:03:47 -06:00
|
|
|
/etc/init.d/network reload
|
|
|
|
/etc/init.d/network restart
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2014-11-12 22:25:41 -07:00
|
|
|
[ -x /usr/local/bin/bbhn-postupgrade ] && /usr/local/bin/bbhn-postupgrade
|
2015-04-05 22:03:50 -06:00
|
|
|
|
2013-11-14 23:11:16 -07:00
|
|
|
# setup nvram variables
|
2013-12-02 13:04:54 -07:00
|
|
|
[ -x /usr/local/bin/nvram-setup ] && /usr/local/bin/nvram-setup
|
2013-11-14 23:11:16 -07:00
|
|
|
|
|
|
|
# run mode specific setup
|
|
|
|
[ -x /etc/config/local ] && /etc/config/local
|
2013-12-02 13:04:54 -07:00
|
|
|
[ -x /etc/local/services ] && /etc/local/services
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|