diff --git a/net/travelmate/Makefile b/net/travelmate/Makefile index fd4e95939..766f7f4b1 100644 --- a/net/travelmate/Makefile +++ b/net/travelmate/Makefile @@ -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 diff --git a/net/travelmate/files/travelmate.init b/net/travelmate/files/travelmate.init index 18d3d0089..b3362b151 100755 --- a/net/travelmate/files/travelmate.init +++ b/net/travelmate/files/travelmate.init @@ -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 } diff --git a/net/travelmate/files/travelmate.sh b/net/travelmate/files/travelmate.sh index fbc142232..545a0b2f7 100755 --- a/net/travelmate/files/travelmate.sh +++ b/net/travelmate/files/travelmate.sh @@ -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,37 +101,40 @@ 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 [ -z "${trm_radio}" ] && [ -z "$(printf "%s" "${trm_radiolist}" | grep -Fo "${radio}")" ] + if [ -n "${config}" ] && [ -n "${radio}" ] && [ -n "${mode}" ] && [ -n "${network}" ] 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 - 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 - 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 - if [ -n "${eaptype}" ] + if [ "${mode}" = "sta" ] && [ "${network}" = "${trm_iface}" ] 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 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 + else uci -q revert wireless f_check "rev" - if [ "${dev}" = "${active_radio}" ] && [ -n "${trm_active_sta}" ] + if [ ${cnt} -eq ${trm_maxretry} ] || ([ "${dev}" = "${active_radio}" ] && [ -n "${trm_active_sta}" ]) 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 - 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 break fi @@ -461,7 +458,18 @@ while true do if [ -z "${trm_action}" ] 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" ] then > "${trm_rtfile}"