Browse Source

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>
lilik-openwrt-22.03
Dirk Brenken 6 years ago
parent
commit
9caef6ca4f
3 changed files with 61 additions and 41 deletions
  1. +1
    -1
      net/travelmate/Makefile
  2. +15
    -3
      net/travelmate/files/travelmate.init
  3. +45
    -37
      net/travelmate/files/travelmate.sh

+ 1
- 1
net/travelmate/Makefile View File

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=travelmate PKG_NAME:=travelmate
PKG_VERSION:=1.3.4
PKG_VERSION:=1.3.5
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>


+ 15
- 3
net/travelmate/files/travelmate.init View File

@ -31,8 +31,20 @@ start_service()
reload_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() stop_service()
@ -68,5 +80,5 @@ service_triggers()
PROCD_RELOAD_DELAY=$((${delay:-2} * 1000)) PROCD_RELOAD_DELAY=$((${delay:-2} * 1000))
procd_add_interface_trigger "interface.*.down" "${trigger}" "${trm_init}" reload 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
} }

+ 45
- 37
net/travelmate/files/travelmate.sh View File

@ -10,7 +10,7 @@
# #
LC_ALL=C LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin" PATH="/usr/sbin:/usr/bin:/sbin:/bin"
trm_ver="1.3.4"
trm_ver="1.3.5"
trm_sysver="unknown" trm_sysver="unknown"
trm_enabled=0 trm_enabled=0
trm_debug=0 trm_debug=0
@ -45,7 +45,7 @@ f_trim()
# #
f_envload() f_envload()
{ {
local sys_call sys_desc sys_model sys_ver
local sys_call sys_desc sys_model
# get system information # get system information
# #
@ -101,37 +101,40 @@ f_envload()
# #
f_prep() 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 mode="$(uci_get wireless "${config}" mode)"
local network="$(uci_get wireless "${config}" network)" local network="$(uci_get wireless "${config}" network)"
local radio="$(uci_get wireless "${config}" device)" local radio="$(uci_get wireless "${config}" device)"
local disabled="$(uci_get wireless "${config}" disabled)" local disabled="$(uci_get wireless "${config}" disabled)"
local eaptype="$(uci_get wireless "${config}" eap_type)" local eaptype="$(uci_get wireless "${config}" eap_type)"
if [ -z "${trm_radio}" ] && [ -z "$(printf "%s" "${trm_radiolist}" | grep -Fo "${radio}")" ]
if [ -n "${config}" ] && [ -n "${radio}" ] && [ -n "${mode}" ] && [ -n "${network}" ]
then then
trm_radiolist="$(f_trim "${trm_radiolist} ${radio}")"
elif [ -n "${trm_radio}" ] && [ -z "${trm_radiolist}" ]
then
trm_radiolist="$(f_trim "$(printf "%s" "${trm_radio}" | \
awk '{while(match(tolower($0),/radio[0-9]/)){ORS=" ";print substr(tolower($0),RSTART,RLENGTH);$0=substr($0,RSTART+RLENGTH)}}')")"
fi
if [ "${mode}" = "sta" ] && [ "${network}" = "${trm_iface}" ]
then
if ([ -z "${disabled}" ] || [ "${disabled}" = "0" ]) && ([ ${proactive} -eq 0 ] || [ "${trm_ifstatus}" != "true" ])
if [ -z "${trm_radio}" ] && [ -z "$(printf "%s" "${trm_radiolist}" | grep -Fo "${radio}")" ]
then then
uci_set wireless "${config}" disabled 1
elif [ "${disabled}" = "0" ] && [ "${trm_ifstatus}" = "true" ] && [ -z "${trm_active_sta}" ] && [ ${proactive} -eq 1 ]
trm_radiolist="$(f_trim "${trm_radiolist} ${radio}")"
elif [ -n "${trm_radio}" ] && [ -z "${trm_radiolist}" ]
then then
trm_active_sta="${config}"
trm_radiolist="$(f_trim "$(printf "%s" "${trm_radio}" | \
awk '{while(match(tolower($0),/radio[0-9]/)){ORS=" ";print substr(tolower($0),RSTART,RLENGTH);$0=substr($0,RSTART+RLENGTH)}}')")"
fi fi
if [ -n "${eaptype}" ]
if [ "${mode}" = "sta" ] && [ "${network}" = "${trm_iface}" ]
then then
eap_rc="$("${trm_wpa}" -veap >/dev/null 2>&1; printf "%u" ${?})"
fi
if [ -z "${eaptype}" ] || [ ${eap_rc} -eq 0 ]
then
trm_stalist="$(f_trim "${trm_stalist} ${config}-${radio}")"
if ([ -z "${disabled}" ] || [ "${disabled}" = "0" ]) && ([ ${proactive} -eq 0 ] || [ "${trm_ifstatus}" != "true" ])
then
uci_set wireless "${config}" disabled 1
elif [ "${disabled}" = "0" ] && [ "${trm_ifstatus}" = "true" ] && [ -z "${trm_active_sta}" ] && [ ${proactive} -eq 1 ]
then
trm_active_sta="${config}"
fi
if [ -n "${eaptype}" ]
then
eap_rc="$("${trm_wpa}" -veap >/dev/null 2>&1; printf "%u" ${?})"
fi
if [ -z "${eaptype}" ] || [ ${eap_rc} -eq 0 ]
then
trm_stalist="$(f_trim "${trm_stalist} ${config}-${radio}")"
fi
fi 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}" 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" ] if [ "${trm_ifstatus}" = "true" ]
then then
uci_commit wireless uci_commit wireless
f_check "initial"
f_log "info" "connected to uplink '${sta_radio}/${sta_essid}/${sta_bssid:-"-"}' (${trm_sysver})" f_log "info" "connected to uplink '${sta_radio}/${sta_essid}/${sta_bssid:-"-"}' (${trm_sysver})"
return 0 return 0
elif [ ${cnt} -eq ${trm_maxretry} ]
then
else
uci -q revert wireless uci -q revert wireless
f_check "rev" f_check "rev"
if [ "${dev}" = "${active_radio}" ] && [ -n "${trm_active_sta}" ]
if [ ${cnt} -eq ${trm_maxretry} ] || ([ "${dev}" = "${active_radio}" ] && [ -n "${trm_active_sta}" ])
then then
f_check "initial"
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 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"
f_jsnup
f_log "info" "can't connect to uplink '${sta_radio}/${sta_essid}/${sta_bssid:-"-"}' (${trm_sysver})"
unset scan_list unset scan_list
break break
fi fi
@ -461,7 +458,18 @@ while true
do do
if [ -z "${trm_action}" ] if [ -z "${trm_action}" ]
then then
sleep ${trm_timeout}
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" ] elif [ "${trm_action}" = "stop" ]
then then
> "${trm_rtfile}" > "${trm_rtfile}"


Loading…
Cancel
Save