aredn/files/etc/init.d/local

53 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=99
boot() {
[ -x /usr/local/bin/aredn_postupgrade ] && /usr/local/bin/aredn_postupgrade
# setup nvram variables
[ -x /usr/local/bin/nvram-setup ] && /usr/local/bin/nvram-setup
# run mode specific setup
[ -x /etc/config/local ] && /etc/config/local
[ -x /etc/local/services ] && /etc/local/services
# set POE passthrough if available
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 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 set aredn.@usb[0].passthrough="$duval"
uci -q commit aredn
usbvalue=$duval
fi
/usr/local/bin/usb_passthrough "${usbvalue}"
# package repositories
local packages_default=$(uci -q get "aredn.@downloads[0].packages_default")
if [ "${packages_default}" != "" ]; then
local repos="core base arednpackages packages luci routing telephony"
set -- $repos
while [ -n "$1" ]; do
local distrepo=$(grep aredn_$1 /etc/opkg/distfeeds.conf | cut -d' ' -f3)
local prefixurl=$(echo $distrepo | sed -n 's/\(http[s]\?:\/\/[^/]\+\).*/\1/p')
if [ "$packages_default" != "$prefixurl" ]; then
sed -i "s|$prefixurl|$packages_default|g" /etc/opkg/distfeeds.conf
fi
shift
done
fi
}