travelmate: update 1.2.3

* remove needless third status "not connected", use only "running / not
connected" and "connected"
* change indentation from spaces to tabs (saves 4kb)
* small fixes
* update readme

Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
Dirk Brenken
2018-09-08 22:28:04 +02:00
parent 3b6e346a4c
commit 1d69658670
4 changed files with 364 additions and 374 deletions
+35 -36
View File
@@ -12,62 +12,61 @@ trm_pidfile="/var/run/travelmate.pid"
boot()
{
ubus -t 30 wait_for network.interface network.wireless 2>/dev/null
rc_procd start_service
ubus -t 30 wait_for network.interface network.wireless 2>/dev/null
rc_procd start_service
}
start_service()
{
if [ $("${trm_init}" enabled; printf "%u" ${?}) -eq 0 ]
then
procd_open_instance "travelmate"
procd_set_param command "${trm_script}" "${@}"
procd_set_param pidfile "${trm_pidfile}"
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
fi
if [ $("${trm_init}" enabled; printf "%u" ${?}) -eq 0 ]
then
procd_open_instance "travelmate"
procd_set_param command "${trm_script}" "${@}"
procd_set_param pidfile "${trm_pidfile}"
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
fi
}
reload_service()
{
[ -s "${trm_pidfile}" ] && return 1
rc_procd start_service
[ -s "${trm_pidfile}" ] && return 1
rc_procd start_service
}
stop_service()
{
rc_procd "${trm_script}" stop
rc_procd start_service
rc_procd "${trm_script}" stop
}
status()
{
local key keylist value rtfile="$(uci_get travelmate global trm_rtfile)"
local key keylist value rtfile="$(uci_get travelmate global trm_rtfile)"
rtfile="${rtfile:-"/tmp/trm_runtime.json"}"
if [ -s "${rtfile}" ]
then
printf "%s\n" "::: travelmate runtime information"
json_load "$(cat "${rtfile}" 2>/dev/null)"
json_select data
json_get_keys keylist
for key in ${keylist}
do
json_get_var value "${key}"
printf " + %-18s : %s\n" "${key}" "${value}"
done
else
printf "%s\n" "::: no travelmate runtime information available"
fi
rtfile="${rtfile:-"/tmp/trm_runtime.json"}"
json_load_file "${rtfile}" >/dev/null 2>&1
json_select data >/dev/null 2>&1
if [ ${?} -eq 0 ]
then
printf "%s\n" "::: travelmate runtime information"
json_get_keys keylist
for key in ${keylist}
do
json_get_var value "${key}"
printf " + %-18s : %s\n" "${key}" "${value}"
done
else
printf "%s\n" "::: no travelmate runtime information available"
fi
}
service_triggers()
{
local trigger="$(uci_get travelmate global trm_iface)"
local delay="$(uci_get travelmate global trm_triggerdelay)"
local trigger="$(uci_get travelmate global trm_iface)"
local delay="$(uci_get travelmate global trm_triggerdelay)"
PROCD_RELOAD_DELAY=$((${delay:-2} * 1000))
procd_add_interface_trigger "interface.*.down" "${trigger}" "${trm_init}" reload
procd_add_reload_trigger "travelmate"
PROCD_RELOAD_DELAY=$((${delay:-2} * 1000))
procd_add_interface_trigger "interface.*.down" "${trigger}" "${trm_init}" reload
procd_add_reload_trigger "travelmate"
}