travelmate: update 1.3.5

* rework procd trigger handling
	- react immediately on if down network events
	- remove needless apply hook in LuCI

Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
Dirk Brenken 2019-02-15 09:29:58 +01:00
parent 2e93d26f51
commit 9caef6ca4f
3 changed files with 62 additions and 42 deletions

View file

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

View file

@ -31,8 +31,20 @@ start_service()
reload_service()
{
[ -s "${trm_pidfile}" ] && return 1
rc_procd start_service
local ppid pid
if [ -s "${trm_pidfile}" ]
then
ppid="$(cat "${trm_pidfile}" 2>/dev/null)"
if [ -n "${ppid}" ]
then
pid="$(pgrep sleep -P ${ppid} 2>/dev/null)"
if [ -n "${pid}" ]
then
kill -INT ${pid} 2>/dev/null
fi
fi
fi
}
stop_service()
@ -68,5 +80,5 @@ service_triggers()
PROCD_RELOAD_DELAY=$((${delay:-2} * 1000))
procd_add_interface_trigger "interface.*.down" "${trigger}" "${trm_init}" reload
procd_add_reload_trigger "travelmate"
procd_add_config_trigger "config.change" "travelmate" "${trm_init}" restart
}

View file

@ -10,7 +10,7 @@
#
LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
trm_ver="1.3.4"
trm_ver="1.3.5"
trm_sysver="unknown"
trm_enabled=0
trm_debug=0
@ -45,7 +45,7 @@ f_trim()
#
f_envload()
{
local sys_call sys_desc sys_model sys_ver
local sys_call sys_desc sys_model
# get system information
#
@ -101,13 +101,15 @@ f_envload()
#
f_prep()
{
local eap_rc=0 config="${1}" proactive="${2}"
local eap_rc=1 config="${1}" proactive="${2}"
local mode="$(uci_get wireless "${config}" mode)"
local network="$(uci_get wireless "${config}" network)"
local radio="$(uci_get wireless "${config}" device)"
local disabled="$(uci_get wireless "${config}" disabled)"
local eaptype="$(uci_get wireless "${config}" eap_type)"
if [ -n "${config}" ] && [ -n "${radio}" ] && [ -n "${mode}" ] && [ -n "${network}" ]
then
if [ -z "${trm_radio}" ] && [ -z "$(printf "%s" "${trm_radiolist}" | grep -Fo "${radio}")" ]
then
trm_radiolist="$(f_trim "${trm_radiolist} ${radio}")"
@ -134,6 +136,7 @@ f_prep()
trm_stalist="$(f_trim "${trm_stalist} ${config}-${radio}")"
fi
fi
fi
f_log "debug" "f_prep ::: config: ${config}, mode: ${mode}, network: ${network}, eap_rc: ${eap_rc}, radio: ${radio}, trm_radio: ${trm_radio:-"-"}, trm_active_sta: ${trm_active_sta:-"-"}, proactive: ${proactive}, disabled: ${disabled}"
}
@ -396,26 +399,20 @@ f_main()
if [ "${trm_ifstatus}" = "true" ]
then
uci_commit wireless
f_check "initial"
f_log "info" "connected to uplink '${sta_radio}/${sta_essid}/${sta_bssid:-"-"}' (${trm_sysver})"
return 0
elif [ ${cnt} -eq ${trm_maxretry} ]
then
uci -q revert wireless
f_check "rev"
if [ "${dev}" = "${active_radio}" ] && [ -n "${trm_active_sta}" ]
then
f_check "initial"
fi
faulty_station="${sta_radio}/${sta_essid}/${sta_bssid:-"-"}"
f_jsnup "${faulty_station}"
f_log "info" "uplink disabled '${sta_radio}/${sta_essid}/${sta_bssid:-"-"}' (${trm_sysver})"
break
else
uci -q revert wireless
f_check "rev"
if [ ${cnt} -eq ${trm_maxretry} ] || ([ "${dev}" = "${active_radio}" ] && [ -n "${trm_active_sta}" ])
then
faulty_station="${sta_radio}/${sta_essid}/${sta_bssid:-"-"}"
f_jsnup "${faulty_station}"
f_log "info" "uplink disabled '${sta_radio}/${sta_essid}/${sta_bssid:-"-"}' (${trm_sysver})"
else
f_jsnup
f_log "info" "can't connect to uplink '${sta_radio}/${sta_essid}/${sta_bssid:-"-"}' (${trm_sysver})"
fi
unset scan_list
break
fi
@ -460,8 +457,19 @@ fi
while true
do
if [ -z "${trm_action}" ]
then
while true
do
f_check "initial"
if [ "${trm_ifstatus}" = "true" ]
then
sleep ${trm_timeout}
fi
if [ $? -eq 0 ] || [ "${trm_ifstatus}" = "false" ]
then
break
fi
done
elif [ "${trm_action}" = "stop" ]
then
> "${trm_rtfile}"