travelmate: update 0.2.4 3412/head
authorDirk Brenken <dev@brenken.org>
Sat, 29 Oct 2016 19:36:09 +0000 (21:36 +0200)
committerDirk Brenken <dev@brenken.org>
Sat, 29 Oct 2016 19:40:12 +0000 (21:40 +0200)
* 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 <dev@brenken.org>
net/travelmate/Makefile
net/travelmate/files/README.md
net/travelmate/files/travelmate.sh

index a1ff7c6e4ef2607f914bdb9e9b28ed7f65f667bf..d9fe2a43205b03a8950e7991cd0496c0544175f3 100644 (file)
@@ -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 <dev@brenken.org>
index 6842dc7e384b4affd86cd3fc65b4d079990dbac3..d74b4b757c28f3e1da4f0f8bcc89ea5ac6cc761e 100644 (file)
@@ -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:**
index b3d160b321cda9dc60e4127734ada7cb3f7db876..f6a9797b15722e034fb086642f65c4add9f2706d 100755 (executable)
 #
 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"