travelmate: update 1.2.0
* union 'automatic' and 'trigger' mode, now much more responsive if an uplink suddenly disappears * tidy up (disable) travelmate related uplink connections if you disable the service * change default config ('trm_automatic' removal) * documentation update * LuCI: remove needless 'automatic' and 'trigger' options plus small fixes Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
parent
e911c7db9d
commit
2d25b194d2
5 changed files with 54 additions and 43 deletions
net/travelmate
|
@ -6,7 +6,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=travelmate
|
PKG_NAME:=travelmate
|
||||||
PKG_VERSION:=1.1.3
|
PKG_VERSION:=1.2.0
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_LICENSE:=GPL-3.0+
|
PKG_LICENSE:=GPL-3.0+
|
||||||
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
||||||
|
|
|
@ -11,24 +11,25 @@ To avoid these kind of deadlocks, travelmate set all station interfaces in an "a
|
||||||
* strong LuCI-Support with builtin interface wizard and a wireless station manager
|
* strong LuCI-Support with builtin interface wizard and a wireless station manager
|
||||||
* fast uplink connections
|
* fast uplink connections
|
||||||
* support all kinds of uplinks, incl. hidden and enterprise uplinks
|
* support all kinds of uplinks, incl. hidden and enterprise uplinks
|
||||||
* trigger- or automatic-mode support, the latter one is the default and checks the existing uplink connection regardless of ifdown event trigger actions every n seconds
|
* continuously checks the existing uplink connection (quality), e.g. for conditional uplink (dis-) connections
|
||||||
* checks continuously the signal quality for conditional uplink (dis-) connections
|
|
||||||
* captive portal detection with internet online check and a 'heartbeat' function to keep the uplink connection up & running
|
* captive portal detection with internet online check and a 'heartbeat' function to keep the uplink connection up & running
|
||||||
* support of devices with multiple radios
|
* support of devices with multiple radios
|
||||||
* procd init and hotplug support
|
* procd init and hotplug support
|
||||||
* runtime information available via LuCI & via 'status' init command
|
* runtime information available via LuCI & via 'status' init command
|
||||||
* status & debug logging to syslog
|
* status & debug logging to syslog
|
||||||
|
* optional: the LuCI frontend shows the WiFi QR codes from all configured Access Points. It allows you to connect your Android or iOS devices to your router’s WiFi using the QR code
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
* [OpenWrt](https://openwrt.org), tested with the stable release series (17.01.x) and with the latest OpenWrt snapshot
|
* [OpenWrt](https://openwrt.org), tested with the stable release series (17.01.x) and with the latest OpenWrt snapshot
|
||||||
* iwinfo for wlan scanning, uclient-fetch for captive portal detection
|
* iwinfo for wlan scanning, uclient-fetch for captive portal detection
|
||||||
|
* optional: qrencode 4.x for QR code support
|
||||||
|
|
||||||
## Installation & Usage
|
## Installation & Usage
|
||||||
* download the package [here](https://downloads.openwrt.org/snapshots/packages/x86_64/packages)
|
* download the package [here](https://downloads.openwrt.org/snapshots/packages/x86_64/packages)
|
||||||
* install 'travelmate' (_opkg install travelmate_)
|
* install 'travelmate' (_opkg install travelmate_)
|
||||||
* configure your network:
|
* configure your network:
|
||||||
* recommended: use the LuCI frontend with builtin interface wizard and a wireless station manager
|
* recommended: use the LuCI frontend with builtin interface wizard and a wireless station manager
|
||||||
* manual: see detailed configure steps below
|
* manual: see detailed configuration steps below
|
||||||
* at least you need one configured AP and one STA interface
|
* at least you need one configured AP and one STA interface
|
||||||
|
|
||||||
## LuCI travelmate companion package
|
## LuCI travelmate companion package
|
||||||
|
@ -40,28 +41,28 @@ To avoid these kind of deadlocks, travelmate set all station interfaces in an "a
|
||||||
* usually the pre-configured travelmate setup works quite well and no manual config overrides are needed, all listed options apply to the 'global' section:
|
* usually the pre-configured travelmate setup works quite well and no manual config overrides are needed, all listed options apply to the 'global' section:
|
||||||
* trm\_enabled => main switch to enable/disable the travelmate service (bool/default: '0', disabled)
|
* trm\_enabled => main switch to enable/disable the travelmate service (bool/default: '0', disabled)
|
||||||
* trm\_debug => enable/disable debug logging (bool/default: '0', disabled)
|
* trm\_debug => enable/disable debug logging (bool/default: '0', disabled)
|
||||||
* trm\_automatic => keep travelmate in an active state (bool/default: '1', enabled)
|
|
||||||
* trm\_captive => enable/disable the captive portal detection (bool/default: '1', enabled)
|
* trm\_captive => enable/disable the captive portal detection (bool/default: '1', enabled)
|
||||||
* trm\_minquality => minimum signal quality threshold as percent for conditional uplink (dis-) connections (int/default: '35', valid range: 20-80)
|
* trm\_minquality => minimum signal quality threshold as percent for conditional uplink (dis-) connections (int/default: '35', valid range: 20-80)
|
||||||
* trm\_maxwait => how long (in seconds) should travelmate wait for a successful wlan interface reload action (int/default: '30', valid range: 20-40)
|
* trm\_maxwait => how long (in seconds) should travelmate wait for a successful wlan interface reload action (int/default: '30', valid range: 20-40)
|
||||||
* trm\_maxretry => how many times should travelmate try to connect to an uplink (int/default: '3', valid range: 1-10)
|
* trm\_maxretry => how many times should travelmate try to connect to an uplink (int/default: '3', valid range: 1-10)
|
||||||
* trm\_timeout => timeout in seconds for "automatic mode" (int/default: '60', valid range: 30-300)
|
* trm\_timeout => overall retry timeout in seconds (int/default: '60', valid range: 30-300)
|
||||||
* trm\_radio => limit travelmate to a dedicated radio, e.g. 'radio0' (default: not set, use all radios)
|
* trm\_radio => limit travelmate to a dedicated radio, e.g. 'radio0' (default: not set, use all radios)
|
||||||
* trm\_iface => main uplink / procd trigger network interface (default: trm_wwan)
|
* trm\_iface => main uplink / procd trigger network interface (default: trm_wwan)
|
||||||
* trm\_triggerdelay => additional trigger delay in seconds before travelmate processing starts (int/default: '2')
|
* trm\_triggerdelay => additional trigger delay in seconds before travelmate processing begins (int/default: '2')
|
||||||
|
|
||||||
## Runtime information
|
## Runtime information
|
||||||
|
|
||||||
**receive travelmate runtime information:**
|
**receive travelmate runtime information:**
|
||||||
<pre><code>
|
<pre><code>
|
||||||
|
~# /etc/init.d/travelmate status
|
||||||
::: travelmate runtime information
|
::: travelmate runtime information
|
||||||
+ travelmate_status : connected (net ok/55)
|
+ travelmate_status : connected (net ok/37)
|
||||||
+ travelmate_version : 1.1.0
|
+ travelmate_version : 1.2.0
|
||||||
+ station_id : Turris/-
|
+ station_id : blackhole/01:02:03:04:05:06
|
||||||
+ station_interface : trm_wwan
|
+ station_interface : trm_wwan
|
||||||
+ station_radio : radio1
|
+ station_radio : radio0
|
||||||
+ last_rundate : 19.02.2018 17:02:25
|
+ last_rundate : 04.04.2018 13:00:24
|
||||||
+ system : GL.iNet GL-AR750, OpenWrt SNAPSHOT r5988+25-60e07ffec5
|
+ system : GL.iNet GL-AR750, OpenWrt SNAPSHOT r6588-16efb0c1c6
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
## Manual Setup
|
## Manual Setup
|
||||||
|
@ -98,7 +99,7 @@ config wifi-iface
|
||||||
option device 'radio0'
|
option device 'radio0'
|
||||||
option network 'trm_wwan'
|
option network 'trm_wwan'
|
||||||
option mode 'sta'
|
option mode 'sta'
|
||||||
option ssid 'example_01'
|
option ssid 'example_usual'
|
||||||
option encryption 'psk2+ccmp'
|
option encryption 'psk2+ccmp'
|
||||||
option key 'abc'
|
option key 'abc'
|
||||||
option disabled '1'
|
option disabled '1'
|
||||||
|
@ -107,7 +108,8 @@ config wifi-iface
|
||||||
option device 'radio0'
|
option device 'radio0'
|
||||||
option network 'trm_wwan'
|
option network 'trm_wwan'
|
||||||
option mode 'sta'
|
option mode 'sta'
|
||||||
option ssid 'example_02'
|
option ssid 'example_hidden'
|
||||||
|
option bssid '00:11:22:33:44:55'
|
||||||
option encryption 'psk2+ccmp'
|
option encryption 'psk2+ccmp'
|
||||||
option key 'xyz'
|
option key 'xyz'
|
||||||
option disabled '1'
|
option disabled '1'
|
||||||
|
@ -121,11 +123,10 @@ edit /etc/config/travelmate and set 'trm_enabled' to '1'
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
**Q:** What's about 'trigger' and 'automatic' mode?
|
|
||||||
**A:** In "trigger" mode travelmate will be triggered solely by procd interface down events, whenever an uplink disappears travelmate tries n times (default 3) to find a new uplink or reconnect to the old one. The 'automatic' mode keeps travelmate in an active state and checks every n seconds the connection status / the uplink availability regardless of procd event trigger.
|
|
||||||
|
|
||||||
**Q:** What happen with misconfigured uplinks, e.g. due to outdated wlan passwords?
|
**Q:** What happen with misconfigured uplinks, e.g. due to outdated wlan passwords?
|
||||||
**A:** Travelmate tries n times (default 3) to connect, then the respective uplink SSID will be marked / renamed to '_SSID_\_err'. In this case use the builtin wireless station manager to update your wireless credentials.
|
**A:** Travelmate tries n times (default 3) to connect, then the respective uplink SSID will be marked / renamed to '_SSID_\_err' and travelmate no longer attends this uplink. In this case use the builtin wireless station manager to update your wireless credentials.
|
||||||
|
**Q:** How to connect to hidden uplinks?
|
||||||
|
**A:** See 'example\_hidden' STA configuration above, option 'SSID' and 'BSSID' must be specified for successful connections.
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
Please join the travelmate discussion in this [forum thread](https://forum.lede-project.org/t/travelmate-support-thread/5155) or contact me by [mail](mailto:dev@brenken.org)
|
Please join the travelmate discussion in this [forum thread](https://forum.lede-project.org/t/travelmate-support-thread/5155) or contact me by [mail](mailto:dev@brenken.org)
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
config travelmate 'global'
|
config travelmate 'global'
|
||||||
option trm_enabled '0'
|
option trm_enabled '0'
|
||||||
option trm_automatic '1'
|
|
||||||
option trm_captive '1'
|
option trm_captive '1'
|
||||||
option trm_iface 'trm_wwan'
|
option trm_iface 'trm_wwan'
|
||||||
option trm_triggerdelay '2'
|
option trm_triggerdelay '2'
|
||||||
|
|
|
@ -8,6 +8,7 @@ EXTRA_HELP=" status Print runtime information"
|
||||||
|
|
||||||
trm_init="/etc/init.d/travelmate"
|
trm_init="/etc/init.d/travelmate"
|
||||||
trm_script="/usr/bin/travelmate.sh"
|
trm_script="/usr/bin/travelmate.sh"
|
||||||
|
trm_pidfile="/var/run/travelmate.pid"
|
||||||
|
|
||||||
boot()
|
boot()
|
||||||
{
|
{
|
||||||
|
@ -27,6 +28,12 @@ start_service()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reload_service()
|
||||||
|
{
|
||||||
|
[ -s "${trm_pidfile}" ] && return 1
|
||||||
|
"${trm_init}" restart
|
||||||
|
}
|
||||||
|
|
||||||
stop_service()
|
stop_service()
|
||||||
{
|
{
|
||||||
local rtfile="$(uci_get travelmate global trm_rtfile)"
|
local rtfile="$(uci_get travelmate global trm_rtfile)"
|
||||||
|
@ -59,15 +66,10 @@ status()
|
||||||
|
|
||||||
service_triggers()
|
service_triggers()
|
||||||
{
|
{
|
||||||
local auto="$(uci_get travelmate global trm_automatic)"
|
|
||||||
|
|
||||||
if [ "${auto}" = "0" ]
|
|
||||||
then
|
|
||||||
local trigger="$(uci_get travelmate global trm_iface)"
|
local trigger="$(uci_get travelmate global trm_iface)"
|
||||||
local delay="$(uci_get travelmate global trm_triggerdelay)"
|
local delay="$(uci_get travelmate global trm_triggerdelay)"
|
||||||
|
|
||||||
PROCD_RELOAD_DELAY=$((${delay:-2} * 1000))
|
PROCD_RELOAD_DELAY=$((${delay:-2} * 1000))
|
||||||
procd_add_interface_trigger "interface.*.down" "${trigger}" "${trm_init}" start
|
procd_add_interface_trigger "interface.*.down" "${trigger}" "${trm_init}" reload
|
||||||
fi
|
|
||||||
procd_add_reload_trigger "travelmate"
|
procd_add_reload_trigger "travelmate"
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,10 @@
|
||||||
#
|
#
|
||||||
LC_ALL=C
|
LC_ALL=C
|
||||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
trm_ver="1.1.3"
|
trm_ver="1.2.0"
|
||||||
trm_sysver="unknown"
|
trm_sysver="unknown"
|
||||||
trm_enabled=0
|
trm_enabled=0
|
||||||
trm_debug=0
|
trm_debug=0
|
||||||
trm_automatic=1
|
|
||||||
trm_captive=1
|
trm_captive=1
|
||||||
trm_captiveurl="http://captive.apple.com"
|
trm_captiveurl="http://captive.apple.com"
|
||||||
trm_minquality=35
|
trm_minquality=35
|
||||||
|
@ -27,6 +26,8 @@ trm_rtfile="/tmp/trm_runtime.json"
|
||||||
trm_fetch="$(command -v uclient-fetch)"
|
trm_fetch="$(command -v uclient-fetch)"
|
||||||
trm_iwinfo="$(command -v iwinfo)"
|
trm_iwinfo="$(command -v iwinfo)"
|
||||||
trm_wpa="$(command -v wpa_supplicant)"
|
trm_wpa="$(command -v wpa_supplicant)"
|
||||||
|
trm_action="${1:-"start"}"
|
||||||
|
trm_pidfile="/var/run/travelmate.pid"
|
||||||
|
|
||||||
# load travelmate environment
|
# load travelmate environment
|
||||||
#
|
#
|
||||||
|
@ -68,6 +69,10 @@ f_envload()
|
||||||
if [ ${trm_enabled} -ne 1 ]
|
if [ ${trm_enabled} -ne 1 ]
|
||||||
then
|
then
|
||||||
f_log "info" "travelmate is currently disabled, please set 'trm_enabled' to '1' to use this service"
|
f_log "info" "travelmate is currently disabled, please set 'trm_enabled' to '1' to use this service"
|
||||||
|
config_load wireless
|
||||||
|
config_foreach f_prep wifi-iface
|
||||||
|
uci_commit wireless
|
||||||
|
ubus call network reload
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -166,7 +171,7 @@ f_check()
|
||||||
fi
|
fi
|
||||||
elif [ "${mode}" = "rev" ]
|
elif [ "${mode}" = "rev" ]
|
||||||
then
|
then
|
||||||
wait=$((${trm_maxwait}/3))
|
wait=$(( ${trm_maxwait} / 3 ))
|
||||||
sleep ${wait}
|
sleep ${wait}
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
|
@ -194,7 +199,7 @@ f_check()
|
||||||
fi
|
fi
|
||||||
if [ "${mode}" = "initial" ] && [ "${trm_captive}" -eq 1 ] && [ "${trm_ifstatus}" = "true" ]
|
if [ "${mode}" = "initial" ] && [ "${trm_captive}" -eq 1 ] && [ "${trm_ifstatus}" = "true" ]
|
||||||
then
|
then
|
||||||
result="$(${trm_fetch} --timeout=$((${trm_maxwait}/3)) --spider "${trm_captiveurl}" 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}')"
|
result="$(${trm_fetch} --timeout=$(( ${trm_maxwait} / 3 )) --spider "${trm_captiveurl}" 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}')"
|
||||||
if [ -n "${result}" ] && ([ -z "${trm_connection}" ] || [ "${result}" != "${trm_connection%/*}" ])
|
if [ -n "${result}" ] && ([ -z "${trm_connection}" ] || [ "${result}" != "${trm_connection%/*}" ])
|
||||||
then
|
then
|
||||||
trm_connection="${result}/${trm_ifquality}"
|
trm_connection="${result}/${trm_ifquality}"
|
||||||
|
@ -204,10 +209,10 @@ f_check()
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
wait=$((wait+1))
|
wait=$(( wait + 1 ))
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
f_log "debug" "f_check::: mode: ${mode}, name: ${ifname:-"-"}, status: ${trm_ifstatus}, quality: ${trm_ifquality}, connection: ${trm_connection:-"-"}, wait: ${wait}, max_wait: ${trm_maxwait}, min_quality: ${trm_minquality}, captive: ${trm_captive}, automatic: ${trm_automatic}"
|
f_log "debug" "f_check::: mode: ${mode}, name: ${ifname:-"-"}, status: ${trm_ifstatus}, quality: ${trm_ifquality}, connection: ${trm_connection:-"-"}, wait: ${wait}, max_wait: ${trm_maxwait}, min_quality: ${trm_minquality}, captive: ${trm_captive}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# update runtime information
|
# update runtime information
|
||||||
|
@ -335,7 +340,6 @@ f_main()
|
||||||
then
|
then
|
||||||
uci_commit wireless
|
uci_commit wireless
|
||||||
f_log "info" "interface '${sta_iface}' on '${sta_radio}' connected to uplink '${sta_essid:-"-"}/${sta_bssid:-"-"}' (${trm_sysver})"
|
f_log "info" "interface '${sta_iface}' on '${sta_radio}' connected to uplink '${sta_essid:-"-"}/${sta_bssid:-"-"}' (${trm_sysver})"
|
||||||
f_check "initial"
|
|
||||||
return 0
|
return 0
|
||||||
elif [ ${cnt} -eq ${trm_maxretry} ]
|
elif [ ${cnt} -eq ${trm_maxretry} ]
|
||||||
then
|
then
|
||||||
|
@ -366,8 +370,8 @@ f_main()
|
||||||
IFS=" "
|
IFS=" "
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
cnt=$((cnt+1))
|
cnt=$(( cnt + 1 ))
|
||||||
sleep $((${trm_maxwait}/6))
|
sleep $(( ${trm_maxwait} / 6 ))
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
if [ ! -s "${trm_rtfile}" ]
|
if [ ! -s "${trm_rtfile}" ]
|
||||||
|
@ -393,12 +397,17 @@ fi
|
||||||
|
|
||||||
# control travelmate actions
|
# control travelmate actions
|
||||||
#
|
#
|
||||||
f_envload
|
while true
|
||||||
f_main
|
|
||||||
while [ ${trm_automatic} -eq 1 ]
|
|
||||||
do
|
do
|
||||||
|
if [ -z "${trm_action}" ]
|
||||||
|
then
|
||||||
|
> "${trm_pidfile}"
|
||||||
sleep ${trm_timeout}
|
sleep ${trm_timeout}
|
||||||
|
else
|
||||||
|
printf '%s' "${$}" > "${trm_pidfile}"
|
||||||
|
trm_action=""
|
||||||
|
fi
|
||||||
f_envload
|
f_envload
|
||||||
f_main
|
f_main
|
||||||
done
|
done
|
||||||
exit 0
|
|
||||||
|
|
Loading…
Reference in a new issue