From 9fc66abcc06db8492493c4b95be151a8ffd95cb4 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Wed, 6 Dec 2017 16:53:43 +0100 Subject: [PATCH] travelmate: update 0.9.5 * change start priority to 25 * add support for hidden uplinks * add support for wpa enterprise uplinks Signed-off-by: Dirk Brenken --- net/travelmate/Makefile | 2 +- net/travelmate/files/README.md | 10 +++--- net/travelmate/files/travelmate.init | 15 ++++----- net/travelmate/files/travelmate.sh | 48 +++++++++++++++++----------- 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/net/travelmate/Makefile b/net/travelmate/Makefile index ea5069870..93bde5d5f 100644 --- a/net/travelmate/Makefile +++ b/net/travelmate/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=travelmate -PKG_VERSION:=0.9.3 +PKG_VERSION:=0.9.5 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 c739b492f..ad14024c6 100644 --- a/net/travelmate/files/README.md +++ b/net/travelmate/files/README.md @@ -10,6 +10,7 @@ To avoid these kind of deadlocks, travelmate set all station interfaces in an "a * easy setup within normal OpenWrt/LEDE environment * strong LuCI-Support with builtin interface wizard and a wireless station manager * fast uplink connections +* support all kinds of uplinks, incl. hidden and enterprise uplinks * 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 * procd init and hotplug support @@ -49,15 +50,14 @@ To avoid these kind of deadlocks, travelmate set all station interfaces in an "a **receive travelmate runtime information:**

-root@adb2go:~# /etc/init.d/travelmate status
 ::: travelmate runtime information
- travelmate_version : 0.9.1
+ travelmate_version : 0.9.5
  station_connection : true
- station_ssid       : blackhole.nl
+ station_id         : blackhole/04:F0:21:2F:B7:64
  station_interface  : trm_wwan
  station_radio      : radio1
- last_rundate       : 29.07.2017 18:02:01
- system             : LEDE Reboot SNAPSHOT r4639-eb43a817f7
+ last_rundate       : 06.12.2017 16:47:56
+ system             : LEDE Reboot SNAPSHOT r5422-9fe59abef8
 
## Manual Setup diff --git a/net/travelmate/files/travelmate.init b/net/travelmate/files/travelmate.init index 40f57f24f..831ab8dc7 100755 --- a/net/travelmate/files/travelmate.init +++ b/net/travelmate/files/travelmate.init @@ -1,6 +1,6 @@ #!/bin/sh /etc/rc.common -START=90 +START=25 USE_PROCD=1 EXTRA_COMMANDS="status" @@ -43,16 +43,15 @@ status() service_triggers() { - local auto="$(uci -q get travelmate.global.trm_automatic)" + local auto="$(uci_get travelmate.global.trm_automatic)" if [ "${auto}" = "0" ] then - local iface="$(uci -q get travelmate.global.trm_iface)" - local delay="$(uci -q get travelmate.global.trm_triggerdelay)" + local trigger="$(uci_get travelmate.global.trm_iface)" + local delay="$(uci_get travelmate.global.trm_triggerdelay)" - PROCD_RELOAD_DELAY=$((${delay:=2} * 1000)) - procd_add_interface_trigger "interface.*.down" "${iface}" "${trm_init}" start + PROCD_RELOAD_DELAY=$((${delay:-2} * 1000)) + procd_add_interface_trigger "interface.*.down" "${trigger}" "${trm_init}" start fi - PROCD_RELOAD_DELAY=1000 - procd_add_config_trigger "config.change" "travelmate" "${trm_init}" start + procd_add_reload_trigger "travelmate" } diff --git a/net/travelmate/files/travelmate.sh b/net/travelmate/files/travelmate.sh index e0d4d258e..ae9573c77 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.9.3" +trm_ver="0.9.5" trm_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')" trm_enabled=0 trm_debug=0 @@ -123,13 +123,13 @@ f_check() # f_jsnupdate() { - local iface="${1}" radio="${2}" ssid="${3}" + local iface="${1}" radio="${2}" essid="${3:-"n/a"}" bssid="${4:-"n/a"}" json_init json_add_object "data" json_add_string "travelmate_version" "${trm_ver}" json_add_string "station_connection" "${trm_ifstatus}" - json_add_string "station_ssid" "${ssid}" + json_add_string "station_id" "${essid}/${bssid}" json_add_string "station_interface" "${iface}" json_add_string "station_radio" "${radio}" json_add_string "last_rundate" "$(/bin/date "+%d.%m.%Y %H:%M:%S")" @@ -180,7 +180,7 @@ f_log() # f_main() { - local dev config ssid_list sta_ssid sta_radio sta_iface cnt=1 + local dev config raw_scan essid_list bssid_list sta_essid sta_bssid sta_radio sta_iface cnt=1 f_check "initial" if [ "${trm_ifstatus}" != "true" ] @@ -203,33 +203,44 @@ f_main() fi while [ ${trm_maxretry} -eq 0 ] || [ ${cnt} -le ${trm_maxretry} ] do - ssid_list="$(${trm_iwinfo} "${dev}" scan | awk '/ESSID: "/{ORS=" ";if (!seen[$0]++) for(i=2; i<=NF; i++) print $i}')" - f_log "debug" "main: ${trm_iwinfo}, dev: ${dev}, ssids: ${ssid_list}" - if [ -n "${ssid_list}" ] + raw_scan="$(${trm_iwinfo} "${dev}" scan)" + essid_list="$(printf "%s" "${raw_scan}" | awk '/ESSID: "/{ORS=" ";if (!seen[$0]++) for(i=2; i<=NF; i++) print $i}')" + bssid_list="$(printf "%s" "${raw_scan}" | awk '/Address: /{ORS=" ";if (!seen[$5]++) print $5}')" + f_log "debug" "main: ${trm_iwinfo}, dev: ${dev}, essid-list: ${essid_list}, bssid-list: ${bssid_list}" + if [ -n "${essid_list}" ] || [ -n "${bssid_list}" ] then for sta in ${trm_stalist} do config="${sta%%_*}" sta_radio="${sta##*_}" - sta_ssid="$(uci -q get wireless."${config}".ssid)" + sta_essid="$(uci -q get wireless."${config}".ssid)" + sta_bssid="$(uci -q get wireless."${config}".bssid)" sta_iface="$(uci -q get wireless."${config}".network)" - if [ -n "$(printf "%s" "${ssid_list}" | grep -Fo "\"${sta_ssid}\"")" ] && [ "${dev}" = "${sta_radio}" ] + if ([ -n "$(printf "%s" "${essid_list}" | grep -Fo "\"${sta_essid}\"")" ] ||\ + [ -n "$(printf "%s" "${bssid_list}" | grep -Fo "${sta_bssid}")" ]) && [ "${dev}" = "${sta_radio}" ] then uci -q set wireless."${config}".disabled=0 f_check "sta" if [ "${trm_ifstatus}" = "true" ] then uci -q commit wireless - f_log "info " "interface '${sta_iface}' on '${sta_radio}' connected to uplink '${sta_ssid}' (${trm_sysver})" - f_jsnupdate "${sta_iface}" "${sta_radio}" "${sta_ssid}" + f_log "info " "interface '${sta_iface}' on '${sta_radio}' connected to uplink '${sta_essid:-"-"}/${sta_bssid:-"-"}' (${trm_sysver})" + f_jsnupdate "${sta_iface}" "${sta_radio}" "${sta_essid}" "${sta_bssid}" return 0 elif [ ${trm_maxretry} -ne 0 ] && [ ${cnt} -eq ${trm_maxretry} ] then uci -q set wireless."${config}".disabled=1 - uci -q set wireless."${config}".ssid="${sta_ssid}_err" + if [ -n "${sta_essid}" ] + then + uci -q set wireless."${config}".ssid="${sta_essid}_err" + fi + if [ -n "${sta_bssid}" ] + then + uci -q set wireless."${config}".bssid="${sta_bssid}_err" + fi uci -q commit wireless f_check "dev" - f_log "info " "can't connect to uplink '${sta_ssid}' (${cnt}/${trm_maxretry}), uplink disabled (${trm_sysver})" + f_log "info " "can't connect to uplink '${sta_essid:-"-"}/${sta_bssid:-"-"}' (${cnt}/${trm_maxretry}), uplink disabled (${trm_sysver})" else if [ ${trm_maxretry} -eq 0 ] then @@ -237,9 +248,9 @@ f_main() fi uci -q revert wireless f_check "dev" - f_log "info " "can't connect to uplink '${sta_ssid}' (${cnt}/${trm_maxretry}) (${trm_sysver})" + f_log "info " "can't connect to uplink '${sta_essid:-"-"}/${sta_bssid:-"-"}' (${cnt}/${trm_maxretry}) (${trm_sysver})" fi - f_jsnupdate "${sta_iface}" "${sta_radio}" "${sta_ssid}" + f_jsnupdate "${sta_iface}" "${sta_radio}" "${sta_essid}" "${sta_bssid}" fi done fi @@ -250,16 +261,17 @@ f_main() if [ ! -s "${trm_rtfile}" ] then trm_ifstatus="false" - f_jsnupdate "n/a" "n/a" "n/a" + f_jsnupdate "n/a" "n/a" "n/a" "n/a" fi else if [ ! -s "${trm_rtfile}" ] then config="$(ubus -S call network.wireless status | jsonfilter -l1 -e '@.*.interfaces[@.config.mode="sta"].section')" sta_radio="$(uci -q get wireless."${config}".device)" - sta_ssid="$(uci -q get wireless."${config}".ssid)" + sta_essid="$(uci -q get wireless."${config}".ssid)" + sta_bssid="$(uci -q get wireless."${config}".bssid)" sta_iface="$(uci -q get wireless."${config}".network)" - f_jsnupdate "${sta_iface}" "${sta_radio}" "${sta_ssid}" + f_jsnupdate "${sta_iface}" "${sta_radio}" "${sta_essid}" "${sta_bssid}" fi fi }