mirror of https://github.com/aredn/aredn.git
158 lines
4.4 KiB
Bash
Executable File
158 lines
4.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# extract auto-generated first boot switch config settings
|
|
# and store them for future use
|
|
if [ ! -f /etc/aredn_include/swconfig ]
|
|
then
|
|
mkdir -p /etc/aredn_include
|
|
touch /etc/aredn_include/swconfig
|
|
i=0
|
|
while true; do
|
|
uci -q get network.\@switch\[$i\] > /dev/null
|
|
status=$?
|
|
if [ $status == 1 ]
|
|
then
|
|
break
|
|
fi
|
|
echo "config switch" >> /etc/aredn_include/swconfig
|
|
echo " option name '`uci -q get network.\@switch\[$i\].name`'" >> /etc/aredn_include/swconfig
|
|
echo " option reset '`uci -q get network.\@switch\[$i\].reset`'" >> /etc/aredn_include/swconfig
|
|
echo " option enable_vlan '`uci -q get network.\@switch\[$i\].enable_vlan`'" >> /etc/aredn_include/swconfig
|
|
echo "" >> /etc/aredn_include/swconfig
|
|
let i++
|
|
done
|
|
|
|
i=0
|
|
while true; do
|
|
uci -q get network.\@switch_vlan\[$i\] > /dev/null
|
|
status=$?
|
|
if [ $status == 1 ]
|
|
then
|
|
break
|
|
fi
|
|
echo "config switch_vlan" >> /etc/aredn_include/swconfig
|
|
echo " option device '`uci -q get network.\@switch_vlan\[$i\].device`'" >> /etc/aredn_include/swconfig
|
|
echo " option vlan '`uci -q get network.\@switch_vlan\[$i\].vlan`'" >> /etc/aredn_include/swconfig
|
|
echo " option ports '`uci -q get network.\@switch_vlan\[$i\].ports`'" >> /etc/aredn_include/swconfig
|
|
echo "" >> /etc/aredn_include/swconfig
|
|
let i++
|
|
done
|
|
|
|
i=0
|
|
while true; do
|
|
uci -q get network.\@switch_port\[$i\] > /dev/null
|
|
status=$?
|
|
if [ $status == 1 ]
|
|
then
|
|
break
|
|
fi
|
|
echo "config switch_port" >> /etc/aredn_include/swconfig
|
|
echo " option device '`uci -q get network.\@switch_port\[$i\].device`'" >> /etc/aredn_include/swconfig
|
|
echo " option port '`uci -q get network.\@switch_port\[$i\].port`'" >> /etc/aredn_include/swconfig
|
|
echo " option pvid '`uci -q get network.\@switch_port\[$i\].pvid`'" >> /etc/aredn_include/swconfig
|
|
echo "" >> /etc/aredn_include/swconfig
|
|
let i++
|
|
done
|
|
|
|
fi
|
|
|
|
# Save system NET LED settings
|
|
if [ ! -f /etc/aredn_include/system_netled ]
|
|
then
|
|
mkdir -p /etc/aredn_include
|
|
touch /etc/aredn_include/system_netled
|
|
|
|
CFG=/etc/board.json
|
|
|
|
. /usr/share/libubox/jshn.sh
|
|
|
|
[ -s $CFG ] || /bin/board_detect || exit 1
|
|
|
|
generate_led() {
|
|
local key="$1"
|
|
local cfg="led_$key"
|
|
|
|
json_select led
|
|
json_select "$key"
|
|
json_get_vars name sysfs type trigger default
|
|
|
|
|
|
case "$type" in
|
|
gpio)
|
|
local gpio inverted
|
|
json_get_vars gpio inverted
|
|
;;
|
|
|
|
netdev)
|
|
local device mode
|
|
json_get_vars device mode
|
|
echo "config led 'led_$1'" >> /etc/aredn_include/system_netled
|
|
echo " option name '$name'" >> /etc/aredn_include/system_netled
|
|
echo " option sysfs '$sysfs'" >> /etc/aredn_include/system_netled
|
|
echo " option trigger 'netdev'" >> /etc/aredn_include/system_netled
|
|
echo " option mode '$mode'" >> /etc/aredn_include/system_netled
|
|
echo " option dev '$device'" >> /etc/aredn_include/system_netled
|
|
echo "" >> /etc/aredn_include/system_netled
|
|
;;
|
|
|
|
usb)
|
|
local device
|
|
json_get_vars device
|
|
;;
|
|
|
|
usbport)
|
|
local ports port
|
|
json_get_values ports ports
|
|
;;
|
|
|
|
rssi)
|
|
local iface minq maxq offset factor
|
|
json_get_vars iface minq maxq offset factor
|
|
;;
|
|
|
|
switch)
|
|
local port_mask speed_mask
|
|
json_get_vars port_mask speed_mask
|
|
echo "config led 'led_$1'" >> /etc/aredn_include/system_netled
|
|
echo " option name '$name'" >> /etc/aredn_include/system_netled
|
|
echo " option sysfs '$sysfs'" >> /etc/aredn_include/system_netled
|
|
echo " option trigger '$trigger'" >> /etc/aredn_include/system_netled
|
|
echo " option port_mask '$port_mask'" >> /etc/aredn_include/system_netled
|
|
echo "" >> /etc/aredn_include/system_netled
|
|
;;
|
|
|
|
portstate)
|
|
local port_state
|
|
json_get_vars port_state
|
|
;;
|
|
|
|
timer|oneshot)
|
|
local delayon delayoff
|
|
json_get_vars delayon delayoff
|
|
;;
|
|
esac
|
|
|
|
json_select ..
|
|
json_select ..
|
|
}
|
|
|
|
|
|
json_init
|
|
json_load "$(cat ${CFG})"
|
|
|
|
|
|
if [ ! -s /etc/aredn_include/system_netled ]; then
|
|
touch /etc/aredn_include/system_netled
|
|
|
|
json_get_keys keys led
|
|
for key in $keys; do generate_led $key; done
|
|
fi
|
|
fi
|
|
|
|
hwtype="$('/usr/local/bin/get_hardwaretype')"
|
|
touch /etc/aredn_include/bridge_ports
|
|
if [ "$hwtype" = "nanostation-m" -o "$hwtype" = "cpe220-v2" -o "$hwtype" = "cpe220-v3" -o "$hwtype" = "cpe210-v1" -o "$hwtype" = "cpe510-v1" -o "$hwtype" = "wbs210-v1" -o "$hwtype" = "wbs210-v2" -o "$hwtype" = "wbs510-v1" -o "$hwtype" = "wbs510-v2" ]; then
|
|
echo " option type 'bridge'" > /etc/aredn_include/bridge_ports
|
|
fi
|
|
|
|
exit 0
|