travelmate: update 0.8.0
* use iwinfo instead iw for wlan scanning, scanning now works on radio-level * enhance multiple radio support: * support STA-only radio configurations, e.g first radio with local AP, second radio with a bunch of STAs (without APs) Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
parent
457b517b8a
commit
aa39c780ef
3 changed files with 40 additions and 39 deletions
|
@ -6,7 +6,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=travelmate
|
PKG_NAME:=travelmate
|
||||||
PKG_VERSION:=0.7.5
|
PKG_VERSION:=0.8.0
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_LICENSE:=GPL-3.0+
|
PKG_LICENSE:=GPL-3.0+
|
||||||
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
||||||
|
@ -17,7 +17,7 @@ define Package/travelmate
|
||||||
SECTION:=net
|
SECTION:=net
|
||||||
CATEGORY:=Network
|
CATEGORY:=Network
|
||||||
TITLE:=A wlan connection manager for travel router
|
TITLE:=A wlan connection manager for travel router
|
||||||
DEPENDS:=+iw
|
DEPENDS:=+iwinfo
|
||||||
PKGARCH:=all
|
PKGARCH:=all
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ To avoid these kind of deadlocks, travelmate set all station interfaces in an "a
|
||||||
* easy setup within normal OpenWrt/LEDE environment
|
* easy setup within normal OpenWrt/LEDE environment
|
||||||
* strong LuCI-Support to simplify the interface setup
|
* strong LuCI-Support to simplify the interface setup
|
||||||
* fast uplink connections
|
* fast uplink connections
|
||||||
* manual / automatic mode support, the latter one checks the existing uplink connection regardless of ifdown event trigger every n seconds
|
* manual / automatic mode support, the latter one checks the existing uplink connection regardless of ifdown event trigger actions every n seconds
|
||||||
* support of devices with multiple radios
|
* support of devices with multiple radios
|
||||||
* procd init and hotplug support
|
* procd init and hotplug support
|
||||||
* runtime information available via LuCI & via 'status' init command
|
* runtime information available via LuCI & via 'status' init command
|
||||||
|
@ -18,7 +18,7 @@ To avoid these kind of deadlocks, travelmate set all station interfaces in an "a
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
* [LEDE](https://www.lede-project.org) 17.01 or latest snapshot
|
* [LEDE](https://www.lede-project.org) 17.01 or latest snapshot
|
||||||
* iw for wlan scanning
|
* iwinfo for wlan scanning
|
||||||
|
|
||||||
## LEDE trunk Installation & Usage
|
## LEDE trunk Installation & Usage
|
||||||
* download the package [here](https://downloads.lede-project.org/snapshots/packages/x86_64/packages)
|
* download the package [here](https://downloads.lede-project.org/snapshots/packages/x86_64/packages)
|
||||||
|
@ -26,7 +26,7 @@ To avoid these kind of deadlocks, travelmate set all station interfaces in an "a
|
||||||
* configure your network:
|
* configure your network:
|
||||||
* automatic: use the LuCI frontend with automatic STA interface setup, that's the recommended way
|
* automatic: use the LuCI frontend with automatic STA interface setup, that's the recommended way
|
||||||
* manual: see detailed configure steps below
|
* manual: see detailed configure steps below
|
||||||
* at least you need one AP and one STA interface configured
|
* at least you need one configured AP and one STA interface
|
||||||
|
|
||||||
## LuCI travelmate companion package
|
## LuCI travelmate companion package
|
||||||
* download the package [here](https://downloads.lede-project.org/snapshots/packages/x86_64/luci)
|
* download the package [here](https://downloads.lede-project.org/snapshots/packages/x86_64/luci)
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
LC_ALL=C
|
LC_ALL=C
|
||||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
trm_ver="0.7.5"
|
trm_ver="0.8.0"
|
||||||
trm_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')"
|
trm_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')"
|
||||||
trm_enabled=0
|
trm_enabled=0
|
||||||
trm_debug=0
|
trm_debug=0
|
||||||
|
@ -18,7 +18,7 @@ trm_automatic=1
|
||||||
trm_maxretry=3
|
trm_maxretry=3
|
||||||
trm_maxwait=30
|
trm_maxwait=30
|
||||||
trm_timeout=60
|
trm_timeout=60
|
||||||
trm_iw="$(command -v iw)"
|
trm_iwinfo="$(command -v iwinfo)"
|
||||||
trm_radio=""
|
trm_radio=""
|
||||||
trm_rtfile="/tmp/trm_runtime.json"
|
trm_rtfile="/tmp/trm_runtime.json"
|
||||||
|
|
||||||
|
@ -32,13 +32,17 @@ else
|
||||||
f_log "error" "system libraries not found"
|
f_log "error" "system libraries not found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# initial wireless recovery
|
||||||
|
#
|
||||||
|
ubus call network.wireless up
|
||||||
|
|
||||||
# f_envload: load travelmate environment
|
# f_envload: load travelmate environment
|
||||||
#
|
#
|
||||||
f_envload()
|
f_envload()
|
||||||
{
|
{
|
||||||
# initialize lists
|
# initialize lists
|
||||||
#
|
#
|
||||||
trm_aplist=""
|
trm_devlist=""
|
||||||
trm_stalist=""
|
trm_stalist=""
|
||||||
trm_radiolist=""
|
trm_radiolist=""
|
||||||
|
|
||||||
|
@ -60,9 +64,9 @@ f_envload()
|
||||||
|
|
||||||
# check for wireless tool
|
# check for wireless tool
|
||||||
#
|
#
|
||||||
if [ -z "${trm_iw}" ]
|
if [ -z "${trm_iwinfo}" ]
|
||||||
then
|
then
|
||||||
f_log "error" "no wireless tool found, please install package 'iw'"
|
f_log "error" "no wireless tool found, please install package 'iwinfo'"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,11 +79,12 @@ f_prepare()
|
||||||
local radio="$(uci -q get wireless."${config}".device)"
|
local radio="$(uci -q get wireless."${config}".device)"
|
||||||
local disabled="$(uci -q get wireless."${config}".disabled)"
|
local disabled="$(uci -q get wireless."${config}".disabled)"
|
||||||
|
|
||||||
if [ "${mode}" = "ap" ] && ([ -z "${disabled}" ] || [ "${disabled}" = "0" ]) && \
|
if ([ -z "${trm_radio}" ] || [ "${trm_radio}" = "${radio}" ]) && \
|
||||||
([ -z "${trm_radio}" ] || [ "${trm_radio}" = "${radio}" ])
|
[ -z "$(printf "%s" "${trm_radiolist}" | grep -Fo " ${radio}")" ]
|
||||||
then
|
then
|
||||||
trm_radiolist="${trm_radiolist} ${radio}"
|
trm_radiolist="${trm_radiolist} ${radio}"
|
||||||
elif [ "${mode}" = "sta" ]
|
fi
|
||||||
|
if [ "${mode}" = "sta" ]
|
||||||
then
|
then
|
||||||
trm_stalist="${trm_stalist} ${config}_${radio}"
|
trm_stalist="${trm_stalist} ${config}_${radio}"
|
||||||
if [ -z "${disabled}" ] || [ "${disabled}" = "0" ]
|
if [ -z "${disabled}" ] || [ "${disabled}" = "0" ]
|
||||||
|
@ -87,7 +92,7 @@ f_prepare()
|
||||||
uci -q set wireless."${config}".disabled=1
|
uci -q set wireless."${config}".disabled=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
f_log "debug" "mode: ${mode}, radio: ${radio}, config: ${config}, disabled: ${disabled}"
|
f_log "debug" "prepare: ${mode}, radio: ${radio}, config: ${config}, disabled: ${disabled}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# f_check: check interface status
|
# f_check: check interface status
|
||||||
|
@ -96,44 +101,43 @@ f_check()
|
||||||
{
|
{
|
||||||
local ifname radio status cnt=1 mode="${1}"
|
local ifname radio status cnt=1 mode="${1}"
|
||||||
|
|
||||||
ubus call network reload
|
|
||||||
trm_ifstatus="false"
|
trm_ifstatus="false"
|
||||||
|
ubus call network reload
|
||||||
while [ ${cnt} -le ${trm_maxwait} ]
|
while [ ${cnt} -le ${trm_maxwait} ]
|
||||||
do
|
do
|
||||||
status="$(ubus -S call network.wireless status 2>/dev/null)"
|
status="$(ubus -S call network.wireless status 2>/dev/null)"
|
||||||
if [ -n "${status}" ]
|
if [ -n "${status}" ]
|
||||||
then
|
then
|
||||||
if [ "${mode}" = "ap" ]
|
if [ "${mode}" = "dev" ]
|
||||||
then
|
then
|
||||||
for radio in ${trm_radiolist}
|
for radio in ${trm_radiolist}
|
||||||
do
|
do
|
||||||
trm_ifstatus="$(printf "%s" "${status}" | jsonfilter -e "@.${radio}.up")"
|
trm_ifstatus="$(printf "%s" "${status}" | jsonfilter -l1 -e "@.${radio}.up")"
|
||||||
if [ "${trm_ifstatus}" = "true" ]
|
if [ "${trm_ifstatus}" = "true" ]
|
||||||
then
|
then
|
||||||
trm_aplist="${trm_aplist} $(printf "%s" "${status}" | jsonfilter -e "@.${radio}.interfaces[@.config.mode=\"ap\"].ifname")_${radio}"
|
trm_devlist="${trm_devlist} ${radio}"
|
||||||
ifname="${trm_aplist}"
|
|
||||||
else
|
else
|
||||||
trm_aplist=""
|
trm_devlist=""
|
||||||
trm_ifstatus="false"
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
ifname="${trm_devlist}"
|
||||||
else
|
else
|
||||||
ifname="$(printf "%s" "${status}" | jsonfilter -e '@.*.interfaces[@.config.mode="sta"].ifname')"
|
ifname="$(printf "%s" "${status}" | jsonfilter -l1 -e '@.*.interfaces[@.config.mode="sta"].ifname')"
|
||||||
if [ -n "${ifname}" ]
|
if [ -n "${ifname}" ]
|
||||||
then
|
then
|
||||||
trm_ifstatus="$(ubus -S call network.interface dump 2>/dev/null | jsonfilter -e "@.interface[@.device=\"${ifname}\"].up")"
|
trm_ifstatus="$(ubus -S call network.interface dump 2>/dev/null | jsonfilter -l1 -e "@.interface[@.device=\"${ifname}\"].up")"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
if [ "${mode}" = "initial" ] || [ "${trm_ifstatus}" = "true" ]
|
||||||
if [ "${mode}" = "initial" ] || [ "${trm_ifstatus}" = "true" ]
|
then
|
||||||
then
|
break
|
||||||
break
|
fi
|
||||||
fi
|
fi
|
||||||
cnt=$((cnt+1))
|
cnt=$((cnt+1))
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
f_log "debug" "mode: ${mode}, name: ${ifname}, status: ${trm_ifstatus}, count: ${cnt}, max-wait: ${trm_maxwait}, automatic: ${trm_automatic}"
|
f_log "debug" "check: ${mode}, name: ${ifname}, status: ${trm_ifstatus}, count: ${cnt}, max-wait: ${trm_maxwait}, automatic: ${trm_automatic}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# f_jsnupdate: update runtime information
|
# f_jsnupdate: update runtime information
|
||||||
|
@ -197,7 +201,7 @@ f_log()
|
||||||
#
|
#
|
||||||
f_main()
|
f_main()
|
||||||
{
|
{
|
||||||
local config ssid_list ap ap_radio sta_ssid sta_radio sta_iface cnt=1
|
local dev config ssid_list sta_ssid sta_radio sta_iface cnt=1
|
||||||
|
|
||||||
f_check "initial"
|
f_check "initial"
|
||||||
if [ "${trm_ifstatus}" != "true" ]
|
if [ "${trm_ifstatus}" != "true" ]
|
||||||
|
@ -209,22 +213,19 @@ f_main()
|
||||||
then
|
then
|
||||||
uci -q commit wireless
|
uci -q commit wireless
|
||||||
fi
|
fi
|
||||||
f_check "ap"
|
f_check "dev"
|
||||||
f_log "debug" "ap-list: ${trm_aplist}, sta-list: ${trm_stalist}"
|
f_log "debug" "main: ${trm_devlist}, sta-list: ${trm_stalist}"
|
||||||
for ap in ${trm_aplist}
|
for dev in ${trm_devlist}
|
||||||
do
|
do
|
||||||
cnt=1
|
cnt=1
|
||||||
ap_radio="${ap##*_}"
|
if [ -z "$(printf "%s" "${trm_stalist}" | grep -Fo "_${dev}")" ]
|
||||||
ap="${ap%%_*}"
|
|
||||||
if [ -z "$(printf "%s" "${trm_stalist}" | grep -Fo "_${ap_radio}")" ]
|
|
||||||
then
|
then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
while [ ${cnt} -le ${trm_maxretry} ]
|
while [ ${cnt} -le ${trm_maxretry} ]
|
||||||
do
|
do
|
||||||
ssid_list="$(${trm_iw} dev "${ap}" scan 2>/dev/null | \
|
ssid_list="$(${trm_iwinfo} "${dev}" scan | awk '/ESSID: "/{ORS=" ";if (!seen[$0]++) for(i=2; i<=NF; i++) print $i}')"
|
||||||
awk '/SSID: /{if(!seen[$0]++){printf "\"";for(i=2; i<=NF; i++)if(i==2)printf $i;else printf " "$i;printf "\" "}}')"
|
f_log "debug" "main: ${trm_iwinfo}, dev: ${dev}, ssids: ${ssid_list}"
|
||||||
f_log "debug" "iw: ${trm_iw}, ap: ${ap}, ssids: ${ssid_list}"
|
|
||||||
if [ -n "${ssid_list}" ]
|
if [ -n "${ssid_list}" ]
|
||||||
then
|
then
|
||||||
for sta in ${trm_stalist}
|
for sta in ${trm_stalist}
|
||||||
|
@ -233,7 +234,7 @@ f_main()
|
||||||
sta_radio="${sta##*_}"
|
sta_radio="${sta##*_}"
|
||||||
sta_ssid="$(uci -q get wireless."${config}".ssid)"
|
sta_ssid="$(uci -q get wireless."${config}".ssid)"
|
||||||
sta_iface="$(uci -q get wireless."${config}".network)"
|
sta_iface="$(uci -q get wireless."${config}".network)"
|
||||||
if [ -n "$(printf "%s" "${ssid_list}" | grep -Fo "\"${sta_ssid}\"")" ] && [ "${ap_radio}" = "${sta_radio}" ]
|
if [ -n "$(printf "%s" "${ssid_list}" | grep -Fo "\"${sta_ssid}\"")" ] && [ "${dev}" = "${sta_radio}" ]
|
||||||
then
|
then
|
||||||
uci -q set wireless."${config}".disabled=0
|
uci -q set wireless."${config}".disabled=0
|
||||||
f_check "sta"
|
f_check "sta"
|
||||||
|
|
Loading…
Reference in a new issue