From b2de32aab03e11148112a9fe009d47f799c13e40 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Sat, 29 Oct 2016 21:36:09 +0200 Subject: [PATCH] travelmate: update 0.2.4 * change option 'trm_iw' to boolean, 1 => use iw (default) 0 => use iwinfo * option 'trm_maxretry' now accepts '0' to disable this check at all * documentation update Signed-off-by: Dirk Brenken --- net/travelmate/Makefile | 2 +- net/travelmate/files/README.md | 6 ++--- net/travelmate/files/travelmate.sh | 39 ++++++++++++++++-------------- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/net/travelmate/Makefile b/net/travelmate/Makefile index a1ff7c6e4..d9fe2a432 100644 --- a/net/travelmate/Makefile +++ b/net/travelmate/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=travelmate -PKG_VERSION:=0.2.3 +PKG_VERSION:=0.2.4 PKG_RELEASE:=1 PKG_LICENSE:=GPL-3.0+ PKG_MAINTAINER:=Dirk Brenken diff --git a/net/travelmate/files/README.md b/net/travelmate/files/README.md index 6842dc7e3..d74b4b757 100644 --- a/net/travelmate/files/README.md +++ b/net/travelmate/files/README.md @@ -33,11 +33,11 @@ To avoid these kind of deadlocks, travelmate set all station interfaces in an "a * mandatory config options: * trm\_enabled => main switch to enable/disable the travelmate service (default: '0', disabled) * trm\_loop => loop timeout in seconds for wlan monitoring (default: '30') - * trm\_maxretry => how many times should travelmate try to connect to a certain uplink (default: '3') + * trm\_maxretry => how many times should travelmate try to connect to a certain uplink, to disable this check at all set it to '0' (default: '3') * optional config options: * trm\_debug => enable/disable debug logging (default: '0', disabled) - * trm\_device => limit travelmate to a dedicated radio, i.e 'radio0' (default: '', use all radios) - * trm\_iw => force travelmate to use iwinfo (even if iw is installed) set this option to 'none' (default: '', use iw if found) + * trm\_device => limit travelmate to a dedicated radio, i.e 'radio0' (default: use all radios) + * trm\_iw => set this option to '0' to use iwinfo for wlan scanning (default: '1', use iw) ## Setup **1. configure a wwan interface in /etc/config/network:** diff --git a/net/travelmate/files/travelmate.sh b/net/travelmate/files/travelmate.sh index b3d160b32..f6a9797b1 100755 --- a/net/travelmate/files/travelmate.sh +++ b/net/travelmate/files/travelmate.sh @@ -10,13 +10,13 @@ # LC_ALL=C PATH="/usr/sbin:/usr/bin:/sbin:/bin" -trm_debug="0" trm_pid="${$}" -trm_ver="0.2.3" +trm_ver="0.2.4" +trm_debug=0 trm_loop=30 trm_maxretry=3 +trm_iw=1 trm_device="" -trm_iw="$(which iw)" # function to prepare all relevant AP and STA interfaces # @@ -106,7 +106,7 @@ trm_check() json_get_var trm_status up if [ "${trm_status}" = "1" ] || [ -n "${trm_uplink}" ] then - trm_log "debug" "check::: interface: ${interface}, status: ${trm_status}, uplink: ${trm_uplink}, ssid: ${trm_ssid} count: ${cnt}" + trm_log "debug" "check::: interface: ${interface}, status: ${trm_status}, uplink-sta: ${trm_uplink}, uplink-ssid: ${trm_ssid} count: ${cnt}" json_cleanup break fi @@ -133,7 +133,7 @@ trm_log() local class="${1}" local log_msg="${2}" - if [ -n "${log_msg}" ] && ([ "${class}" != "debug" ] || ([ "${class}" = "debug" ] && [ "${trm_debug}" = "1" ])) + if [ -n "${log_msg}" ] && ([ "${class}" != "debug" ] || ([ "${class}" = "debug" ] && [ $((trm_debug)) -eq 1 ])) then logger -t "travelmate-${trm_ver}[${trm_pid}] ${class}" "${log_msg}" 2>&1 fi @@ -170,14 +170,17 @@ fi # check for preferred wireless tool # -if [ ! -f "${trm_iw}" ] +if [ $((trm_iw)) -eq 1 ] then - trm_iwinfo="$(which iwinfo)" - if [ ! -f "${trm_iwinfo}" ] - then - trm_log "error" "no wireless tool for wlan scanning found, please install 'iw' or 'iwinfo'" - exit 255 - fi + trm_scanner="$(which iw)" +else + trm_scanner="$(which iwinfo)" +fi + +if [ -z "${trm_scanner}" ] +then + trm_log "error" "no wireless tool for wlan scanning found, please install 'iw' or 'iwinfo'" + exit 255 fi # infinitive loop to establish and track STA uplink connections @@ -195,13 +198,13 @@ do for ap in ${trm_aplist} do ubus -t 10 wait_for hostapd."${ap}" - if [ -f "${trm_iw}" ] + if [ $((trm_iw)) -eq 1 ] then - trm_ssidlist="$(${trm_iw} dev "${ap}" scan 2>/dev/null | awk '/SSID: /{if(!seen[$0]++){printf "\"";for(i=2; i<=NF; i++)if(i==2)printf $i;else printf " "$i;printf "\" "}}')" + trm_ssidlist="$(${trm_scanner} dev "${ap}" scan 2>/dev/null | awk '/SSID: /{if(!seen[$0]++){printf "\"";for(i=2; i<=NF; i++)if(i==2)printf $i;else printf " "$i;printf "\" "}}')" else - trm_ssidlist="$(${trm_iwinfo} "${ap}" scan | awk '/ESSID: ".*"/{ORS=" ";if (!seen[$0]++) for(i=2; i<=NF; i++) print $i}')" + trm_ssidlist="$(${trm_scanner} "${ap}" scan | awk '/ESSID: ".*"/{ORS=" ";if (!seen[$0]++) for(i=2; i<=NF; i++) print $i}')" fi - trm_log "debug" "main ::: iw: ${trm_iw}, iwinfo: ${trm_iwinfo}, ssidlist: ${trm_ssidlist}" + trm_log "debug" "main ::: scan-tool: ${trm_scanner}, ssidlist: ${trm_ssidlist}" if [ -n "${trm_ssidlist}" ] then for sta in ${trm_stalist} @@ -210,7 +213,7 @@ do trm_network="${sta##*_}" trm_ifname="$(uci -q get wireless."${trm_config}".ifname)" trm_ssid="\"$(uci -q get wireless."${trm_config}".ssid)\"" - if [ $((trm_count_${trm_config}_${trm_network})) -lt $((trm_maxretry)) ] + if [ $((trm_count_${trm_config}_${trm_network})) -lt $((trm_maxretry)) ] || [ $((trm_maxretry)) -eq 0 ] then if [ -n "$(printf "${trm_ssidlist}" | grep -Fo "${trm_ssid}")" ] then @@ -227,7 +230,7 @@ do eval "trm_count_${trm_config}_${trm_network}=\$((trm_count_${trm_config}_${trm_network}+1))" fi fi - elif [ $((trm_count_${trm_config}_${trm_network})) -eq $((trm_maxretry)) ] + elif [ $((trm_count_${trm_config}_${trm_network})) -eq $((trm_maxretry)) ] && [ $((trm_maxretry)) -ne 0 ] then eval "trm_count_${trm_config}_${trm_network}=\$((trm_count_${trm_config}_${trm_network}+1))" trm_log "info" "uplink ${trm_ssid} disabled due to permanent connection failures"