You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.7 KiB

  1. #!/bin/sh /etc/rc.common
  2. START=25
  3. USE_PROCD=1
  4. EXTRA_COMMANDS="status"
  5. EXTRA_HELP=" status Print runtime information"
  6. trm_init="/etc/init.d/travelmate"
  7. trm_script="/usr/bin/travelmate.sh"
  8. trm_pidfile="/var/run/travelmate.pid"
  9. boot()
  10. {
  11. ubus -t 30 wait_for network.interface network.wireless 2>/dev/null
  12. rc_procd start_service
  13. }
  14. start_service()
  15. {
  16. if [ $("${trm_init}" enabled; printf "%u" ${?}) -eq 0 ]
  17. then
  18. procd_open_instance "travelmate"
  19. procd_set_param command "${trm_script}" "${@}"
  20. procd_set_param pidfile "${trm_pidfile}"
  21. procd_set_param stdout 1
  22. procd_set_param stderr 1
  23. procd_close_instance
  24. fi
  25. }
  26. reload_service()
  27. {
  28. [ -s "${trm_pidfile}" ] && return 1
  29. rc_procd start_service
  30. }
  31. stop_service()
  32. {
  33. rc_procd "${trm_script}" stop
  34. rc_procd start_service
  35. }
  36. status()
  37. {
  38. local key keylist value rtfile="$(uci_get travelmate global trm_rtfile)"
  39. rtfile="${rtfile:-"/tmp/trm_runtime.json"}"
  40. if [ -s "${rtfile}" ]
  41. then
  42. printf "%s\n" "::: travelmate runtime information"
  43. json_load "$(cat "${rtfile}" 2>/dev/null)"
  44. json_select data
  45. json_get_keys keylist
  46. for key in ${keylist}
  47. do
  48. json_get_var value "${key}"
  49. printf " + %-18s : %s\n" "${key}" "${value}"
  50. done
  51. else
  52. printf "%s\n" "::: no travelmate runtime information available"
  53. fi
  54. }
  55. service_triggers()
  56. {
  57. local trigger="$(uci_get travelmate global trm_iface)"
  58. local delay="$(uci_get travelmate global trm_triggerdelay)"
  59. PROCD_RELOAD_DELAY=$((${delay:-2} * 1000))
  60. procd_add_interface_trigger "interface.*.down" "${trigger}" "${trm_init}" reload
  61. procd_add_reload_trigger "travelmate"
  62. }