Browse Source

travelmate: update 0.6.0

* rework automatic mode (active scan/re-connection handling):
   * much more procd & resource friendly
   * now enabled by default
* save runtime information in ubus service (data section)
* final backend preparation for new LuCI-GUI (still WIP!)
* documentation update

Signed-off-by: Dirk Brenken <dev@brenken.org>
lilik-openwrt-22.03
Dirk Brenken 8 years ago
parent
commit
cf919894d6
5 changed files with 85 additions and 49 deletions
  1. +1
    -1
      net/travelmate/Makefile
  2. +29
    -13
      net/travelmate/files/README.md
  3. +2
    -2
      net/travelmate/files/travelmate.conf
  4. +0
    -5
      net/travelmate/files/travelmate.init
  5. +53
    -28
      net/travelmate/files/travelmate.sh

+ 1
- 1
net/travelmate/Makefile View File

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=travelmate
PKG_VERSION:=0.5.0
PKG_VERSION:=0.6.0
PKG_RELEASE:=1
PKG_LICENSE:=GPL-3.0+
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>


+ 29
- 13
net/travelmate/files/README.md View File

@ -9,10 +9,10 @@ To avoid these kind of deadlocks, travelmate set all station interfaces in an "a
* STA interfaces operating in an "always off" mode, to make sure that the AP is always accessible
* easy setup within normal OpenWrt/LEDE environment
* fast uplink connections
* "active mode" support, where travelmate will be restarted every n seconds (default 60) and checks the existing uplink connection regardless of ifdown event trigger
* 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
* procd init system support
* procd based hotplug support, the travelmate start will be triggered by interface triggers
* procd init and hotplug support
* runtime information accessible via ubus service call
* status & debug logging to syslog
## Prerequisites
@ -32,23 +32,39 @@ To avoid these kind of deadlocks, travelmate set all station interfaces in an "a
* the application is located in LuCI under 'Services' menu
* _Thanks to Hannu Nyman for this great LuCI frontend!_
## Chaos Calmer installation notes
* 'travelmate' and 'luci-app-travelmate' are _not_ available as ipk packages in the Chaos Calmer download repository
* download the packages from a development snapshot directory (see download links above)
* manually transfer the packages to your routers temp directory (with tools like _sshfs_ or _winscp_)
* install the packages as described above
## Travelmate config options
* travelmate config options:
* trm\_enabled => main switch to enable/disable the travelmate service (default: '0', disabled)
* trm\_debug => enable/disable debug logging (default: '0', disabled)
* trm\_active => keep travelmate in an active state (default: '0', disabled)
* trm\_maxwait => how long (in seconds) should travelmate wait for wlan interface reload action (default: '20')
* trm\_automatic => keep travelmate in an active state (default: '1', enabled)
* 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 "active mode" (default: '60')
* 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: not set, disabled)
* trm\_iface => restrict the procd interface trigger to a (list of) certain wan interface(s) or disable it at all (default: wan wwan)
## Runtime information
**receive travelmate information via ubus:**
<pre><code>
ubus call service get_data '{"name":"travelmate"}'
This will output the current connection status, e.g.:
{
"travelmate": {
"travelmate": {
"last_rundate": "02.04.2017 07:22:03",
"online_status": "true",
"station_interface": "wwan",
"station_radio": "radio1",
"station_ssid": "blackhole",
"system": "LEDE Reboot SNAPSHOT r3888-8fb39f1682",
"travelmate_version": "0.6.0"
}
}
}
</code></pre>
## Setup
**1. configure a wwan interface in /etc/config/network:**


+ 2
- 2
net/travelmate/files/travelmate.conf View File

@ -4,8 +4,8 @@
config travelmate 'global'
option trm_enabled '0'
option trm_debug '0'
option trm_iface 'wan wwan'
option trm_active '0'
option trm_iface 'wwan'
option trm_automatic '1'
option trm_maxwait '30'
option trm_maxretry '3'
option trm_timeout '60'


+ 0
- 5
net/travelmate/files/travelmate.init View File

@ -24,11 +24,6 @@ start_service()
fi
}
stop_service()
{
killall -q -TERM "travelmate.sh"
}
service_triggers()
{
local iface="$(uci -q get travelmate.global.trm_iface)"


+ 53
- 28
net/travelmate/files/travelmate.sh View File

@ -10,28 +10,34 @@
#
LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
trm_ver="0.5.0"
trm_ver="0.6.0"
trm_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')"
trm_enabled=1
trm_enabled=0
trm_debug=0
trm_active=0
trm_automatic=0
trm_maxwait=30
trm_maxretry=3
trm_timeout=60
trm_iw=1
# source required system library
#
if [ -r "/lib/functions.sh" ]
then
. "/lib/functions.sh"
else
f_log "error" "required system library not found"
fi
# f_envload: load travelmate environment
#
f_envload()
{
# source required system libraries
# initialize lists
#
if [ -r "/lib/functions.sh" ]
then
. "/lib/functions.sh"
else
f_log "error" "required system library not found"
fi
trm_aplist=""
trm_stalist=""
trm_radiolist=""
# load uci config and check 'enabled' option
#
@ -125,20 +131,34 @@ f_check()
cnt=$((cnt+1))
sleep 1
done
f_log "debug" "mode: ${mode}, name: ${ifname}, status: ${trm_ifstatus}, count: ${cnt}, max-wait: ${trm_maxwait}"
f_log "debug" "mode: ${mode}, name: ${ifname}, status: ${trm_ifstatus}, count: ${cnt}, max-wait: ${trm_maxwait}, automatic: ${trm_automatic}"
}
# f_active: keep travelmate in an active state
# f_ubus: update ubus service
#
f_active()
f_ubus()
{
if [ ${trm_active} -eq 1 ]
then
(sleep ${trm_timeout}; /etc/init.d/travelmate start >/dev/null 2>&1) &
fi
local active_triggers iface="${1}" radio="${2}" ssid="${3}"
for name in ${trm_iface}
do
active_triggers="${active_triggers}[\"interface.*.down\",[\"if\",[\"eq\",\"interface\",\"${name}\"],[\"run_script\",\"/etc/init.d/travelmate\",\"start\"],1000]],"
done
active_triggers="${active_triggers}[\"config.change\",[\"if\",[\"eq\",\"package\",\"travelmate\"],[\"run_script\",\"/etc/init.d/travelmate\",\"start\"],1000]]"
ubus call service add "{\"name\":\"travelmate\",
\"instances\":{\"travelmate\":{\"command\":[\"/usr/bin/travelmate.sh\"],
\"data\":{\"travelmate_version\":\"${trm_ver}\",
\"station_interface\":\"${iface}\",
\"station_radio\":\"${radio}\",
\"station_ssid\":\"${ssid}\",
\"last_rundate\":\"$(/bin/date "+%d.%m.%Y %H:%M:%S")\",
\"online_status\":\"${trm_ifstatus}\",
\"system\":\"${trm_sysver}\"}}},
\"triggers\":[${active_triggers}]}"
}
# f_log: function to write to syslog
# f_log: write to syslog, exit on error
#
f_log()
{
@ -151,7 +171,6 @@ f_log()
if [ "${class}" = "error" ]
then
logger -t "travelmate-[${trm_ver}] ${class}" "Please check 'https://github.com/openwrt/packages/blob/master/net/travelmate/files/README.md' (${trm_sysver})"
f_active
exit 255
fi
fi
@ -161,7 +180,7 @@ f_log()
#
f_main()
{
local ssid_list config ap_radio sta_radio ssid cnt=1
local config ssid_list ap ap_radio sta_ssid sta_radio sta_iface cnt=1
f_check "initial"
if [ "${trm_ifstatus}" != "true" ]
@ -172,6 +191,7 @@ f_main()
then
uci -q commit wireless
ubus call network reload
sleep 5
fi
f_check "ap"
f_log "debug" "ap-list: ${trm_aplist}, sta-list: ${trm_stalist}"
@ -205,8 +225,9 @@ f_main()
do
config="${sta%%_*}"
sta_radio="${sta##*_}"
ssid="\"$(uci -q get wireless."${config}".ssid)\""
if [ -n "$(printf "${ssid_list}" | grep -Fo "${ssid}")" ] && [ "${ap_radio}" = "${sta_radio}" ]
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}" ]
then
uci -q set wireless."${config}".disabled=0
ubus call network reload
@ -214,13 +235,15 @@ f_main()
if [ "${trm_ifstatus}" = "true" ]
then
uci -q commit wireless
f_log "info " "wwan interface connected to uplink ${ssid} (${trm_sysver})"
f_log "info " "interface '${sta_iface}' on '${sta_radio}' connected to uplink '${sta_ssid}' (${trm_sysver})"
sleep 5
f_ubus "${sta_iface}" "${sta_radio}" "${sta_ssid}"
return 0
else
uci -q revert wireless
ubus call network reload
f_log "info " "wwan interface can't connect to uplink ${ssid} (${trm_sysver})"
f_log "info " "interface '${sta_iface}' on '${sta_radio}' can't connect to uplink '${sta_ssid}' (${trm_sysver})"
f_ubus "${sta_iface}" "${sta_radio}" "${sta_ssid}"
fi
fi
done
@ -233,9 +256,11 @@ f_main()
}
f_envload
if [ ${trm_active} -eq 0 ] || ([ ${trm_active} -eq 1 ] && [ $(pgrep -f "/usr/bin/travelmate.sh" | wc -l) -eq 3 ])
then
f_main
while [ ${trm_automatic} -eq 1 ]
do
sleep ${trm_timeout}
f_envload
f_main
f_active
fi
done
exit 0

Loading…
Cancel
Save