travelmate: release 1.4.0 8302/head
authorDirk Brenken <dev@brenken.org>
Tue, 26 Feb 2019 20:11:51 +0000 (21:11 +0100)
committerDirk Brenken <dev@brenken.org>
Wed, 27 Feb 2019 14:08:28 +0000 (15:08 +0100)
* various small tweaks & fixes
* widely tested, ready for forthcoming 19.x branching

Signed-off-by: Dirk Brenken <dev@brenken.org>
net/travelmate/Makefile
net/travelmate/files/travelmate.sh

index e989162e86bf17df7d6ee0ca2c94be8a3c45f794..c34c44103ce25ee9b67b0417511519e2e455b480 100644 (file)
@@ -6,7 +6,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=travelmate
-PKG_VERSION:=1.3.7
+PKG_VERSION:=1.4.0
 PKG_RELEASE:=1
 PKG_LICENSE:=GPL-3.0+
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
index c280dff51ce753ad84da90d92fe14e92f4425eff..f5e5a663b72b3a8d0f77611bf8e04f7bfaa76ff0 100755 (executable)
@@ -10,7 +10,7 @@
 #
 LC_ALL=C
 PATH="/usr/sbin:/usr/bin:/sbin:/bin"
-trm_ver="1.3.7"
+trm_ver="1.4.0"
 trm_sysver="unknown"
 trm_enabled=0
 trm_debug=0
@@ -145,17 +145,12 @@ f_prep()
 #
 f_check()
 {
-       local IFS ifname radio dev_status config sta_essid sta_bssid result cp_domain wait=1 mode="${1}" status="${2:-"false"}"
+       local IFS ifname radio dev_status last_status config sta_essid sta_bssid result cp_domain wait=1 mode="${1}" status="${2:-"false"}"
 
        trm_ifquality=0
-       if [ "${mode}" = "initial" ]
+       if [ "${mode}" != "initial" ] && [ "${status}" = "false" ]
        then
-               trm_ifstatus="false"
-       else
-               if [ "${status}" = "false" ]
-               then
-                       ubus call network reload
-               fi
+               ubus call network reload
        fi
        while [ ${wait} -le ${trm_maxwait} ]
        do
@@ -197,7 +192,7 @@ f_check()
                                        if [ ${trm_ifquality} -ge ${trm_minquality} ]
                                        then
                                                trm_ifstatus="$(ubus -S call network.interface dump 2>/dev/null | jsonfilter -l1 -e "@.interface[@.device=\"${ifname}\"].up")"
-                                       elif [ "${mode}" = "initial" ] && [ ${trm_ifquality} -lt ${trm_minquality} ]
+                                       elif [ "${mode}" = "initial" ] && [ ${trm_ifquality} -lt ${trm_minquality} ] && [ "${trm_ifstatus}" != "${status}" ]
                                        then
                                                trm_ifstatus="${status}"
                                                sta_essid="$(printf "%s" "${dev_status}" | jsonfilter -l1 -e '@.*.interfaces[@.config.mode="sta"].*.ssid')"
@@ -208,16 +203,17 @@ f_check()
                        fi
                        if [ "${mode}" = "initial" ] || [ "${trm_ifstatus}" = "true" ]
                        then
-                               if ([ "${trm_ifstatus}" != "true" ] && [ "${trm_ifstatus}" != "${status}" ]) || \
+                               json_get_var last_status "travelmate_status"
+                               if ([ "${trm_ifstatus}" = "false" ] && [ "${trm_ifstatus}" != "${status}" ]) || \
                                        ([ "${trm_ifstatus}" = "true" ] && [ "${mode}" = "sta" ] && [ -n "${trm_active_sta}" ]) || \
-                                       [ ${trm_ifquality} -lt ${trm_minquality} ]
+                                       [ -z "${last_status}" ] || [ "${last_status}" = "running / not connected" ] || [ ${trm_ifquality} -lt ${trm_minquality} ]
                                then
                                        f_jsnup
                                fi
                                if [ "${mode}" = "initial" ] && [ ${trm_captive} -eq 1 ] && [ "${trm_ifstatus}" = "true" ]
                                then
                                        result="$(${trm_fetch} --timeout=$(( ${trm_maxwait} / 3 )) "${trm_captiveurl}" -O /dev/null 2>&1 | \
-                                               awk '/^Redirected/{printf "%s" "net cp \047"$NF"\047";exit}/^Download completed/{printf "%s" "net ok";exit}/^Failed|^Connection error/{printf "%s" "net nok";exit}')"
+                                               awk '/^Failed to redirect|^Redirected/{printf "%s" "net cp \047"$NF"\047";exit}/^Download completed/{printf "%s" "net ok";exit}/^Failed|^Connection error/{printf "%s" "net nok";exit}')"
                                        if [ -n "${result}" ] && ([ -z "${trm_connection}" ] || [ "${result}" != "${trm_connection%/*}" ])
                                        then
                                                cp_domain="$(printf "%s" "${result}" | awk -F "['| ]" '/^net cp/{printf "%s" $4}')"
@@ -411,7 +407,7 @@ f_main()
                                                                        then
                                                                                uci_commit wireless
                                                                                f_log "info" "connected to uplink '${sta_radio}/${sta_essid}/${sta_bssid:-"-"}' (${trm_sysver})"
-                                                                               return 0
+                                                                               return
                                                                        else
                                                                                uci -q revert wireless
                                                                                f_check "rev"
@@ -436,8 +432,8 @@ f_main()
                                done
                                cnt=$(( cnt + 1 ))
                                sleep $(( ${trm_maxwait} / 6 ))
+                               unset scan_list
                        done
-                       unset scan_list
                done
        fi
 }
@@ -469,14 +465,20 @@ while true
 do
        if [ -z "${trm_action}" ]
        then
+               rc=0
                while true
                do
-                       f_check "initial"
-                       if [ "${trm_ifstatus}" = "true" ]
+                       if [ ${rc} -eq 0 ]
+                       then
+                               f_check "initial"
+                       fi
+                       sleep ${trm_timeout} 0
+                       rc=${?}
+                       if [ ${rc} -ne 0 ]
                        then
-                               sleep ${trm_timeout} 0
+                               f_check "initial"
                        fi
-                       if [ $? -eq 0 ] || [ "${trm_ifstatus}" = "false" ]
+                       if [ ${rc} -eq 0 ] || ([ ${rc} -ne 0 ] && [ "${trm_ifstatus}" = "false" ])
                        then
                                break
                        fi