From b76aacc60a665c4d78ea2df774411ff417376950 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Sat, 6 May 2017 07:33:52 +0200 Subject: [PATCH] travelmate: update 0.7.2 backend: * remove redundant 'iwinfo' support & add 'iw' package dependency * refine stop action & json runtime housekeeping * various small fixes * documentation update frontend (see LuCI repo): * simplify uplink interface setup (just one Click! ;-), now part of the overview tab * cosmetics Signed-off-by: Dirk Brenken --- net/travelmate/Makefile | 3 ++- net/travelmate/files/README.md | 36 ++++++++++++++-------------- net/travelmate/files/travelmate.conf | 5 ++-- net/travelmate/files/travelmate.init | 14 ++++++++++- net/travelmate/files/travelmate.sh | 34 +++++++++----------------- 5 files changed, 46 insertions(+), 46 deletions(-) diff --git a/net/travelmate/Makefile b/net/travelmate/Makefile index ed5d6c5fb3..a5ffe4660f 100644 --- a/net/travelmate/Makefile +++ b/net/travelmate/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=travelmate -PKG_VERSION:=0.7.1 +PKG_VERSION:=0.7.2 PKG_RELEASE:=1 PKG_LICENSE:=GPL-3.0+ PKG_MAINTAINER:=Dirk Brenken @@ -17,6 +17,7 @@ define Package/travelmate SECTION:=net CATEGORY:=Network TITLE:=A wlan connection manager for travel router + DEPENDS:=+iw PKGARCH:=all endef diff --git a/net/travelmate/files/README.md b/net/travelmate/files/README.md index 626956452a..3d3f82101f 100644 --- a/net/travelmate/files/README.md +++ b/net/travelmate/files/README.md @@ -8,6 +8,7 @@ To avoid these kind of deadlocks, travelmate set all station interfaces in an "a ## Main Features * STA interfaces operating in an "always off" mode, to make sure that the AP is always accessible * easy setup within normal OpenWrt/LEDE environment +* strong LuCI-Support to simplify the interface setup * fast uplink connections * manual / automatic mode support, the latter one checks the existing uplink connection regardless of ifdown event trigger every n seconds * support of devices with multiple radios @@ -17,14 +18,14 @@ To avoid these kind of deadlocks, travelmate set all station interfaces in an "a ## Prerequisites * [LEDE](https://www.lede-project.org) 17.01 or latest snapshot -* iw (default) or iwinfo for wlan scanning +* iw for wlan scanning ## LEDE trunk Installation & Usage * download the package [here](https://downloads.lede-project.org/snapshots/packages/x86_64/packages) * install 'travelmate' (_opkg install travelmate_) -* configure your network to support (multiple) wlan uplinks and set travelmate config options (see below) -* set 'trm\_enabled' option in travelmate config to '1' -* travelmate starts automatically during boot and will be triggered by procd interface triggers +* configure your network: + * automatic: use the LuCI frontend with automatic interface setup, that's the recommended way + * manual: see detailed configure steps below ## LuCI travelmate companion package * download the package [here](https://downloads.lede-project.org/snapshots/packages/x86_64/luci) @@ -39,31 +40,30 @@ To avoid these kind of deadlocks, travelmate set all station interfaces in an "a * trm\_maxwait => how long (in seconds) should travelmate wait for a successful wlan interface reload action (default: '30') * trm\_maxretry => how many times should travelmate try to find an uplink after a trigger event (default: '3') * trm\_timeout => timeout in seconds for "automatic mode" (default: '60') - * trm\_iw => set this option to '0' to use iwinfo for wlan scanning (default: '1', use iw) * trm\_radio => limit travelmate to a dedicated radio, e.g. 'radio0' (default: not set, use all radios) - * trm\_iface => restrict the procd interface trigger to a (list of) certain wan interface(s) or disable it at all (default: wwan) - * trm\_triggerdelay => additional trigger delay in seconds before travelmate processing starts (default: '2') + * trm\_iface => restrict the procd interface trigger to a (list of) certain wan interface(s) or disable it at all (default: trm_wwan) + * trm\_triggerdelay => additional trigger delay in seconds before travelmate processing starts (default: '1') ## Runtime information **receive travelmate runtime information:**

-root@adb2go:/tmp# /etc/init.d/travelmate status
+root@adb2go:~# /etc/init.d/travelmate status
 ::: travelmate runtime information
- travelmate_version : 0.7.0
+ travelmate_version : 0.7.2
  station_connection : true
  station_ssid       : blackhole
- station_interface  : wwan
+ station_interface  : trm_wwan
  station_radio      : radio1
- last_rundate       : 20.04.2017 08:54:48
- system             : LEDE Reboot SNAPSHOT r3974-56457dbcb7
+ last_rundate       : 06.05.2017 06:58:22
+ system             : LEDE Reboot SNAPSHOT r4051-3ddc1914ba
 
## Setup -**1. configure a wwan interface in /etc/config/network:** +**1. configure the travelmate wwan interface in /etc/config/network:**

 [...]
-config interface 'wwan'
+config interface 'trm_wwan'
         option proto 'dhcp'
 [...]
 
@@ -73,7 +73,7 @@ config interface 'wwan' [...] config zone option name 'wan' - option network 'wan wan6 wwan' + option network 'wan wan6 trm_wwan' [...] @@ -91,7 +91,7 @@ config wifi-iface [...] config wifi-iface option device 'radio0' - option network 'wwan' + option network 'trm_wwan' option mode 'sta' option ssid 'example_01' option encryption 'psk2+ccmp' @@ -99,7 +99,7 @@ config wifi-iface option disabled '1' config wifi-iface option device 'radio0' - option network 'wwan' + option network 'trm_wwan' option mode 'sta' option ssid 'example_02' option encryption 'psk2+ccmp' @@ -107,7 +107,7 @@ config wifi-iface option disabled '1' config wifi-iface option device 'radio0' - option network 'wwan' + option network 'trm_wwan' option mode 'sta' option ssid 'example_03' option encryption 'none' diff --git a/net/travelmate/files/travelmate.conf b/net/travelmate/files/travelmate.conf index 91b426f1bc..5674ed2e7b 100644 --- a/net/travelmate/files/travelmate.conf +++ b/net/travelmate/files/travelmate.conf @@ -4,11 +4,10 @@ config travelmate 'global' option trm_enabled '0' option trm_debug '0' - option trm_iface 'wwan' - option trm_triggerdelay '2' + option trm_triggerdelay '1' option trm_automatic '1' option trm_maxwait '30' option trm_maxretry '3' option trm_timeout '60' - option trm_iw '1' + option trm_iface 'trm_wwan' option trm_rtfile '/tmp/trm_runtime.json' diff --git a/net/travelmate/files/travelmate.init b/net/travelmate/files/travelmate.init index 6663dd173d..4d1ecc8696 100755 --- a/net/travelmate/files/travelmate.init +++ b/net/travelmate/files/travelmate.init @@ -17,7 +17,7 @@ boot() start_service() { - if [ $("${trm_init}" enabled; printf ${?}) -eq 0 ] + if [ $("${trm_init}" enabled; printf "%u" ${?}) -eq 0 ] then procd_open_instance "travelmate" procd_set_param command "${trm_script}" "${@}" @@ -27,6 +27,18 @@ start_service() fi } +stop_service() +{ + local rtfile="$(uci -q get travelmate.global.trm_rtfile)" + + rtfile="${rtfile:="/tmp/trm_runtime.json"}" + if [ -s "${rtfile}" ] + then + > "${rtfile}" + fi + rc_procd start_service +} + status() { rc_procd "${trm_script}" status diff --git a/net/travelmate/files/travelmate.sh b/net/travelmate/files/travelmate.sh index 6b9637336f..7919d3035a 100755 --- a/net/travelmate/files/travelmate.sh +++ b/net/travelmate/files/travelmate.sh @@ -10,7 +10,7 @@ # LC_ALL=C PATH="/usr/sbin:/usr/bin:/sbin:/bin" -trm_ver="0.7.1" +trm_ver="0.7.2" trm_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')" trm_enabled=0 trm_debug=0 @@ -18,7 +18,7 @@ trm_automatic=1 trm_maxretry=3 trm_maxwait=30 trm_timeout=60 -trm_iw=1 +trm_iw="$(command -v iw)" trm_rtfile="/tmp/trm_runtime.json" # source required system library @@ -57,17 +57,11 @@ f_envload() exit 0 fi - # check for preferred wireless tool + # check for wireless tool # - if [ ${trm_iw} -eq 1 ] + if [ -z "${trm_iw}" ] then - trm_scanner="$(which iw)" - else - trm_scanner="$(which iwinfo)" - fi - if [ -z "${trm_scanner}" ] - then - f_log "error" "no wireless tool for wlan scanning found, please install 'iw' or 'iwinfo'" + f_log "error" "no wireless tool found, please install package 'iw'" fi } @@ -169,7 +163,7 @@ f_status() json_get_keys keylist for key in ${keylist} do - json_get_var value ${key} + json_get_var value "${key}" printf " %-18s : %s\n" "${key}" "${value}" done fi @@ -220,21 +214,15 @@ f_main() cnt=1 ap_radio="${ap##*_}" ap="${ap%%_*}" - if [ -z "$(printf "${trm_stalist}" | grep -Fo "_${ap_radio}")" ] + if [ -z "$(printf "%s" "${trm_stalist}" | grep -Fo "_${ap_radio}")" ] then continue fi while [ ${cnt} -le ${trm_maxretry} ] do - if [ ${trm_iw} -eq 1 ] - then - ssid_list="$(${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 - ssid_list="$(${trm_scanner} "${ap}" scan | \ - awk '/ESSID: ".*"/{ORS=" ";if (!seen[$0]++) for(i=2; i<=NF; i++) print $i}')" - fi - f_log "debug" "scanner: ${trm_scanner}, ap: ${ap}, ssids: ${ssid_list}" + ssid_list="$(${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 "\" "}}')" + f_log "debug" "iw: ${trm_iw}, ap: ${ap}, ssids: ${ssid_list}" if [ -n "${ssid_list}" ] then for sta in ${trm_stalist} @@ -243,7 +231,7 @@ f_main() sta_radio="${sta##*_}" sta_ssid="$(uci -q get wireless."${config}".ssid)" sta_iface="$(uci -q get wireless."${config}".network)" - if [ -n "$(printf "${ssid_list}" | grep -Fo "\"${sta_ssid}\"")" ] && [ "${ap_radio}" = "${sta_radio}" ] + if [ -n "$(printf "%s" "${ssid_list}" | grep -Fo "\"${sta_ssid}\"")" ] && [ "${ap_radio}" = "${sta_radio}" ] then uci -q set wireless."${config}".disabled=0 ubus call network reload -- 2.30.2