travelmate: update 2.4.5-2
authorDirk Brenken <redacted>
Sat, 16 May 2026 17:55:27 +0000 (19:55 +0200)
committerDirk Brenken <redacted>
Sat, 16 May 2026 17:55:53 +0000 (19:55 +0200)
- gated config sanity checks at the end of travelmate-functions.sh
   behind 'trm_action' to fix init script enable/disable/help paths
- added a ubus socket guard around f_system to harden against pre-ubus sourcing
- added a 'trm_bver' fallback in f_log for sourcing paths without prior f_system execution
- reordered system utility references before system library sourcing,
   so f_log has a valid 'trm_logcmd' available if the library check fails
- minor code improvements

Signed-off-by: Dirk Brenken <redacted>
net/travelmate/Makefile
net/travelmate/files/travelmate-functions.sh
net/travelmate/files/travelmate-service.sh

index 4bc8f96251fe4c9d2f91f38e98e70b6c2b4a272d..663a81d95b433166f0a156f0260cc3d7cc2673ff 100644 (file)
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=travelmate
 PKG_VERSION:=2.4.5
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_LICENSE:=GPL-3.0-or-later
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
 
index e1336d5dba9a4bffa8425da24e4ae2fff5f4272d..8a27a0ece251264649af6ba759a5f5dac99b22d4 100644 (file)
@@ -135,15 +135,14 @@ f_conf() {
        #
        if [ "${trm_action}" = "stop" ]; then
                return 0
-       elif [ "${trm_enabled}" != "1" ]; then
-               f_log "info" "travelmate is currently disabled, please set 'trm_enabled' to '1' to use this service"
-               /etc/init.d/travelmate stop
        elif [ -z "${trm_iface}" ]; then
                f_log "info" "travelmate is currently not configured, please use the 'Interface Wizard' in LuCI"
                /etc/init.d/travelmate stop
+               return 0
        elif ! "${trm_ubuscmd}" -t "${trm_maxwait}" wait_for network.wireless network.interface."${trm_iface}" >/dev/null 2>&1; then
                f_log "info" "travelmate interface '${trm_iface}' does not appear on ubus, please check your network setup"
                /etc/init.d/travelmate stop
+               return 0
        fi
 
        # apply wifi-device config, commit and reload on changes
@@ -1189,13 +1188,13 @@ f_log() {
 
        if [ -n "${log_msg}" ] && { [ "${class}" != "debug" ] || [ "${trm_debug}" = "1" ]; }; then
                if [ -x "${trm_logcmd}" ]; then
-                       "${trm_logcmd}" -p "${class}" -t "trm-${trm_bver}[${$}]" "${log_msg::512}"
+                       "${trm_logcmd}" -p "${class}" -t "trm-${trm_bver:-"-"}[${$}]" "${log_msg::512}"
                else
-                       printf "%s %s %s\n" "${class}" "trm-${trm_bver}[${$}]" "${log_msg::512}" >&2
+                       printf "%s %s %s\n" "${class}" "trm-${trm_bver:-"-"}[${$}]" "${log_msg::512}" >&2
                fi
                if [ "${class}" = "err" ] || [ "${class}" = "emerg" ]; then
                        trm_ifstatus="error"
-                       f_genstatus
+                       [ -s "${trm_rtfile}" ] && f_genstatus
                        : >"${trm_pidfile}"
                        exit 1
                fi
@@ -1488,16 +1487,6 @@ f_main() {
        fi
 }
 
-# source required system libraries
-#
-if [ -r "/lib/functions.sh" ] && [ -r "/lib/functions/network.sh" ] && [ -r "/usr/share/libubox/jshn.sh" ]; then
-       . "/lib/functions.sh"
-       . "/lib/functions/network.sh"
-       . "/usr/share/libubox/jshn.sh"
-else
-       f_log "err" "system libraries not found"
-fi
-
 # reference required system utilities
 #
 trm_catcmd="$(f_cmd cat)"
@@ -1514,8 +1503,23 @@ trm_ifstatuscmd="$(f_cmd ifstatus)"
 trm_ipcalccmd="$(f_cmd ipcalc.sh)"
 trm_mailcmd="$(f_cmd msmtp optional)"
 
-f_system
-if [ "${trm_action}" != "stop" ]; then
+# source required system libraries
+#
+if [ -r "/lib/functions.sh" ] && [ -r "/lib/functions/network.sh" ] && [ -r "/usr/share/libubox/jshn.sh" ]; then
+       . "/lib/functions.sh"
+       . "/lib/functions/network.sh"
+       . "/usr/share/libubox/jshn.sh"
+else
+       f_log "err" "system libraries not found"
+fi
+
+# initial system check
+#
+[ -S "/var/run/ubus/ubus.sock" ] && f_system
+
+# entry point
+#
+if [ -n "${trm_action}" ] && [ "${trm_action}" != "stop" ]; then
        [ ! -d "/etc/travelmate" ] && f_log "err" "no travelmate config directory"
        [ ! -r "/etc/config/travelmate" ] && f_log "err" "no travelmate config"
        [ "$(uci_get travelmate global trm_enabled)" = "0" ] && f_log "err" "travelmate is disabled"
index c7957fcf85885b896f174c0f209e3e6cfb2f2a42..441bcd178d9b21d61211892b427d36c78946799d 100755 (executable)
@@ -12,12 +12,20 @@ export LC_ALL=C
 export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
 trm_funlib="/usr/lib/travelmate-functions.sh"
 trm_action="${1}"
-[ -z "${trm_bver}" ] && . "${trm_funlib}"
-f_conf
+
+# source required system libraries and perform initial checks
+#
+if [ -z "${trm_bver}" ]; then
+       . "${trm_funlib}"
+       f_conf
+fi
 
 # control travelmate actions
 #
 while :; do
+
+       # handle service stop and start actions, then execute main loop
+       #
        if [ "${trm_action}" = "stop" ]; then
                if [ -s "${trm_pidfile}" ]; then
                        f_log "info" "travelmate instance stopped ::: action: ${trm_action}, pid: $("${trm_catcmd}" "${trm_pidfile}")"
@@ -30,6 +38,9 @@ while :; do
                f_main
                trm_action=""
        fi
+
+       # wait for next action
+       #
        while :; do
                sleep "${trm_timeout}" 0 >/dev/null 2>&1
                rc="${?}"
git clone https://git.99rst.org/PROJECT