mirror of
https://github.com/openwrt/packages.git
synced 2026-05-31 06:51:51 +08:00
a8f776e152
- 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 <dev@brenken.org>
56 lines
1.3 KiB
Bash
Executable File
56 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# travelmate service script, a wlan connection manager for travel router
|
|
# Copyright (c) 2016-2026 Dirk Brenken (dev@brenken.org)
|
|
# This is free software, licensed under the GNU General Public License v3.
|
|
|
|
# set (s)hellcheck exceptions
|
|
# shellcheck disable=all
|
|
|
|
# initial defaults
|
|
#
|
|
export LC_ALL=C
|
|
export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
|
trm_funlib="/usr/lib/travelmate-functions.sh"
|
|
trm_action="${1}"
|
|
|
|
# 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}")"
|
|
: >"${trm_rtfile}"
|
|
: >"${trm_pidfile}"
|
|
fi
|
|
break
|
|
elif [ -n "${trm_action}" ]; then
|
|
f_log "info" "travelmate instance started ::: action: ${trm_action}, pid: ${$}"
|
|
f_main
|
|
trm_action=""
|
|
fi
|
|
|
|
# wait for next action
|
|
#
|
|
while :; do
|
|
sleep "${trm_timeout}" 0 >/dev/null 2>&1
|
|
rc="${?}"
|
|
if [ "${rc}" != "0" ]; then
|
|
[ "$(f_getgw)" = "false" ] && rc="0"
|
|
fi
|
|
[ "${rc}" = "0" ] && break
|
|
done
|
|
json_cleanup
|
|
f_conf
|
|
f_main
|
|
done
|