mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
map-agent: add config generator script
This commit is contained in:
parent
c08342b404
commit
077337b0ea
2 changed files with 198 additions and 0 deletions
|
|
@ -219,3 +219,8 @@ reload_service() {
|
|||
stop
|
||||
start
|
||||
}
|
||||
|
||||
boot() {
|
||||
/lib/wifi/multiap conf
|
||||
start
|
||||
}
|
||||
|
|
|
|||
193
map-agent/files/lib/multiap/map_genconfig
Normal file
193
map-agent/files/lib/multiap/map_genconfig
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
generate_mapagent_config=0
|
||||
generate_wireless_sta_config=0
|
||||
|
||||
network_mode="$(fw_printenv -n netmode)"
|
||||
multiap_mode="$(fw_printenv -n multiap_mode)"
|
||||
|
||||
is_airoha() {
|
||||
[ -f /proc/device-tree/compatible ] || return
|
||||
strings /proc/device-tree/compatible | grep -qE '^(econet,|airoha,)'; return
|
||||
}
|
||||
|
||||
is_broadcom() {
|
||||
[ -e /dev/bcm ] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
is_qualcomm() {
|
||||
[ -f /proc/device-tree/compatible ] || return
|
||||
strings /proc/device-tree/compatible | grep -qE '^(qcom,|ipq,)'; return
|
||||
}
|
||||
|
||||
generate_multiap_config() {
|
||||
devidx=0
|
||||
|
||||
generate_config() {
|
||||
dev="$1"
|
||||
|
||||
[ -n "$dev" ] || continue
|
||||
|
||||
config_get band $dev band
|
||||
|
||||
mode_band=""
|
||||
priority=
|
||||
dpp_chan=
|
||||
|
||||
case "$band" in
|
||||
2g)
|
||||
mode_band=2
|
||||
priority=2
|
||||
dpp_chan="81/1"
|
||||
;;
|
||||
5g)
|
||||
mode_band=5
|
||||
priority=1
|
||||
dpp_chan="128/36"
|
||||
;;
|
||||
6g)
|
||||
mode_band=6
|
||||
priority=0
|
||||
dpp_chan="133/49"
|
||||
;;
|
||||
esac
|
||||
|
||||
[ -n "$mode_band" ] || continue
|
||||
|
||||
devidx=$(echo ${dev} |tr -dc '0-9')
|
||||
|
||||
device="$dev"
|
||||
|
||||
if is_airoha; then
|
||||
ifprefix="wlan%_%"
|
||||
ifname="wlan${devidx}_0"
|
||||
ifname_bh="wlan${devidx}_1"
|
||||
elif is_broadcom; then
|
||||
ifprefix="wl"
|
||||
ifname="wl${devidx}"
|
||||
ifname_bh="$ifname.1"
|
||||
device="wl${devidx}"
|
||||
brcm_setup="1"
|
||||
elif is_qualcomm; then
|
||||
ifprefix="wlan%%"
|
||||
ifname="wlan${devidx}"
|
||||
ifname_bh="wlan${devidx}-1"
|
||||
else
|
||||
ifprefix="wlan%-%"
|
||||
ifname="wlan$devidx"
|
||||
ifname_bh="$ifname-0"
|
||||
fi
|
||||
|
||||
if [ $generate_mapagent_config -eq 1 ]; then
|
||||
uci set mapagent.agent.ifprefix="$ifprefix"
|
||||
uci set mapagent.agent.brcm_setup="$brcm_setup"
|
||||
uci add mapagent radio
|
||||
uci set mapagent.@radio[-1].device="$device"
|
||||
uci set mapagent.@radio[-1].band="$mode_band"
|
||||
|
||||
if [ "$network_mode" == "extender" ]; then
|
||||
uci add mapagent bsta
|
||||
uci set mapagent.@bsta[-1].device="$device"
|
||||
uci set mapagent.@bsta[-1].ifname="$ifname"
|
||||
uci set mapagent.@bsta[-1].band="$mode_band"
|
||||
uci set mapagent.@bsta[-1].priority="$priority"
|
||||
|
||||
#uci add mapagent dpp_uri
|
||||
#uci set mapagent.@dpp_uri[-1].type="qrcode"
|
||||
#uci set mapagent.@dpp_uri[-1].device="$device"
|
||||
#uci set mapagent.@dpp_uri[-1].ifname="$ifname"
|
||||
#uci set mapagent.@dpp_uri[-1].band="$mode_band"
|
||||
#uci set mapagent.@dpp_uri[-1].chirp_interval="10"
|
||||
#uci add_list mapagent.@dpp_uri[-1].dpp_chan="$dpp_chan"
|
||||
|
||||
if [ $generate_wireless_sta_config -eq 1 ]; then
|
||||
secname="default_sta_${device}"
|
||||
uci set wireless.$secname=wifi-iface
|
||||
uci set wireless.$secname.device="$device"
|
||||
uci set wireless.$secname.mode="sta"
|
||||
uci set wireless.$secname.ifname="$ifname"
|
||||
uci set wireless.$secname.disabled="0"
|
||||
uci set wireless.$secname.default_disabled="1"
|
||||
uci set wireless.$secname.multi_ap="1"
|
||||
uci commit wireless
|
||||
else
|
||||
ubus call uci set "{\"config\":\"wireless\",\"type\":\"wifi-iface\", \
|
||||
\"match\":{\"mode\":\"sta\", \"ifname\":\"$ifname\", \"device\":\"$device\"},\"values\":{\"multi_ap\":\"1\"}}" 2>/dev/null
|
||||
fi
|
||||
else
|
||||
uci add mapagent ap
|
||||
uci set mapagent.@ap[-1].type="fronthaul"
|
||||
uci set mapagent.@ap[-1].device="$device"
|
||||
uci set mapagent.@ap[-1].ifname="$ifname"
|
||||
uci set mapagent.@ap[-1].band="$mode_band"
|
||||
uci add mapagent ap
|
||||
uci set mapagent.@ap[-1].type="backhaul"
|
||||
uci set mapagent.@ap[-1].device="$device"
|
||||
uci set mapagent.@ap[-1].ifname="$ifname_bh"
|
||||
uci set mapagent.@ap[-1].band="$mode_band"
|
||||
|
||||
if [ "$multiap_mode" != "none" ]; then
|
||||
ubus call uci set "{\"config\":\"wireless\",\"type\":\"wifi-iface\", \
|
||||
\"match\":{\"ifname\":\"$ifname\", \"device\":\"$device\"},\"values\":{\"multi_ap\":\"2\"}}" 2>/dev/null
|
||||
ubus call uci set "{\"config\":\"wireless\",\"type\":\"wifi-iface\", \
|
||||
\"match\":{\"ifname\":\"$ifname_bh\", \"device\":\"$device\"},\"values\":{\"multi_ap\":\"1\"}}" 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
config_load wireless
|
||||
config_foreach generate_config wifi-device
|
||||
}
|
||||
|
||||
map_genconf () {
|
||||
if [ -f /etc/config/mapagent -a -z "$(uci -q get mapagent.@radio[0].band)" ]; then
|
||||
generate_mapagent_config=1
|
||||
fi
|
||||
|
||||
if [ "$network_mode" == "extender" ]; then
|
||||
if ! uci show wireless | grep -q "mode=.*sta"; then
|
||||
generate_wireless_sta_config=1
|
||||
|
||||
if is_broadcom; then
|
||||
for section in $(uci show wireless | grep wifi-device | cut -d'.' -f2 | cut -d'=' -f1); do
|
||||
uci -q set wireless.$section.apsta="1"
|
||||
done
|
||||
fi
|
||||
|
||||
for section in $(uci show wireless | grep "mode=.*ap" | cut -d'.' -f2); do
|
||||
uci delete wireless.$section
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
generate_multiap_config
|
||||
|
||||
if [ $generate_mapagent_config -eq 1 ]; then
|
||||
uci set mapagent.agent.enabled="1"
|
||||
if [ "$multiap_mode" == "agent" ]; then
|
||||
uci -q set mapagent.@controller_select[0].autostart=0
|
||||
uci -q set mapagent.@controller_select[0].local=0
|
||||
elif [ "$multiap_mode" == "auto" ]; then
|
||||
uci -q set mapagent.@controller_select[0].autostart=1
|
||||
uci -q set mapagent.@controller_select[0].local=0
|
||||
elif [ "$multiap_mode" == "full" ]; then
|
||||
uci -q set mapagent.@controller_select[0].autostart=1
|
||||
uci -q set mapagent.@controller_select[0].local=1
|
||||
elif [ "$multiap_mode" == "none" ]; then
|
||||
uci set mapagent.agent.enabled="0"
|
||||
fi
|
||||
uci -q commit mapagent
|
||||
fi
|
||||
|
||||
|
||||
if [ "$multiap_mode" == "agent" -o "$multiap_mode" == "none" ]; then
|
||||
uci set mapcontroller.controller.enabled="0"
|
||||
else
|
||||
uci set mapcontroller.controller.enabled="1"
|
||||
fi
|
||||
uci -q commit mapcontroller
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue