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
|
|
|
if [ ! -f /etc/aredn_include/ethmacfixup ]
|
|
|
|
then
|
|
|
|
mkdir -p /etc/aredn_include
|
|
|
|
touch /etc/aredn_include/ethmacfixup
|
2018-12-02 18:52:48 -07:00
|
|
|
local lanintf="$(uci -q get 'network.lan.ifname')"
|
|
|
|
lanintf=${lanintf%% *}
|
|
|
|
local wifiintf="$(uci -q get 'network.wifi.ifname')"
|
2015-07-02 20:03:47 -06:00
|
|
|
local lanmac=`ifconfig $lanintf | grep -o -E '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}'`
|
|
|
|
local wifimac=`ifconfig $wifiintf | grep -o -E '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}'`
|
2018-09-01 17:39:19 -06:00
|
|
|
|
|
|
|
local intlanmac=${lanmac//:/}
|
|
|
|
local intwanmac=${wifimac//:/}
|
|
|
|
local macdelta=$((0x$intwanmac - 0x$intlanmac))
|
2015-07-02 20:03:47 -06:00
|
|
|
|
2018-05-19 23:39:51 -06:00
|
|
|
# Deal with lan and wifi having same mac address (common on TP-Link)
|
2018-09-01 17:39:19 -06:00
|
|
|
# Deal with lan mac + ~10 = wifi mac address (common on Microtik and
|
2018-05-19 23:39:51 -06:00
|
|
|
# breaks OLSR if using derived IP addresses)
|
2018-09-01 17:39:19 -06:00
|
|
|
if [ $macdelta -le 10 ]
|
2015-07-02 20:03:47 -06:00
|
|
|
then
|
2018-05-19 23:39:51 -06:00
|
|
|
local wifimacdigit=`printf "%X" $(((0x${wifimac:9:2} + 1) % 256))`
|
|
|
|
local newmac=${wifimac:0:9}${wifimacdigit}${wifimac:11}
|
|
|
|
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
|
|
|
|
/etc/init.d/network reload
|
|
|
|
/etc/init.d/network restart
|
2015-07-02 20:03:47 -06:00
|
|
|
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
|
2018-10-26 20:34:16 -06:00
|
|
|
|
|
|
|
# set POE passthrough if available
|
2018-11-16 21:41:58 -07:00
|
|
|
local poevalue=$(uci -q get aredn.@poe[0].passthrough)
|
|
|
|
if [ -z "$poevalue" ]; then
|
|
|
|
local dpval=$(jsonfilter -e '@.gpioswitch.poe_passthrough.default' < /etc/board.json)
|
|
|
|
if [ ! -z "$dpval" ]; then
|
|
|
|
uci -q add aredn poe
|
|
|
|
uci -q set aredn.@poe[0].passthrough="$dpval"
|
|
|
|
uci -q commit aredn
|
|
|
|
poevalue=$dpval
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
/usr/local/bin/poe_passthrough "${poevalue}"
|
|
|
|
|
|
|
|
# set USB passthrough if available
|
|
|
|
local usbvalue=$(uci -q get aredn.@usb[0].passthrough)
|
|
|
|
if [ -z "$usbvalue" ]; then
|
|
|
|
local duval=$(jsonfilter -e '@.gpioswitch.usb_power_switch.default' < /etc/board.json)
|
|
|
|
uci -q add aredn usb
|
|
|
|
uci -q set aredn.@usb[0].passthrough="$duval"
|
|
|
|
uci -q commit aredn
|
|
|
|
usbvalue=$duval
|
2018-10-26 20:34:16 -06:00
|
|
|
fi
|
2018-11-29 21:15:16 -07:00
|
|
|
/usr/local/bin/usb_passthrough "${usbvalue}"
|
2020-04-03 14:58:30 -06:00
|
|
|
|
2020-08-18 15:17:03 -06:00
|
|
|
# package repositories
|
2020-04-03 14:58:30 -06:00
|
|
|
local repos="core base arednpackages packages luci routing telephony"
|
|
|
|
set -- $repos
|
|
|
|
while [ -n "$1" ]; do
|
|
|
|
local ucirepo=$(uci -q get aredn.@downloads[0].pkgs_$1)
|
|
|
|
local distrepo=$(grep aredn_$1 /etc/opkg/distfeeds.conf | cut -d' ' -f3)
|
|
|
|
# get the URLs from distfeeds.conf and set the initial UCI values if not present
|
|
|
|
if [ -z $ucirepo ]; then
|
|
|
|
uci set aredn.@downloads[0].pkgs_$1=$distrepo
|
|
|
|
uci commit aredn
|
|
|
|
uci -c /etc/config.mesh set aredn.@downloads[0].pkgs_$1=$distrepo
|
|
|
|
uci -c /etc/config.mesh commit aredn
|
|
|
|
# check values in distfeeds.conf against UCI settings
|
|
|
|
# and change distfeeds.conf if needed (upgrades?)
|
2020-09-25 21:48:28 -06:00
|
|
|
elif [ $ucirepo != $distrepo ]; then
|
|
|
|
sed -i "s|$distrepo|$ucirepo|g" /etc/opkg/distfeeds.conf
|
2020-04-03 14:58:30 -06:00
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
2020-08-18 15:17:03 -06:00
|
|
|
|
2021-11-11 11:08:49 -07:00
|
|
|
if [ -z "$(uci -q get aredn.@alerts[0])" ]; then
|
2020-08-18 15:17:03 -06:00
|
|
|
uci -q add aredn alerts
|
|
|
|
uci -q commit aredn
|
|
|
|
fi
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|