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.

72 lines
1.5 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. }
  35. status()
  36. {
  37. local key keylist value rtfile="$(uci_get travelmate global trm_rtfile)"
  38. rtfile="${rtfile:-"/tmp/trm_runtime.json"}"
  39. json_load_file "${rtfile}" >/dev/null 2>&1
  40. json_select data >/dev/null 2>&1
  41. if [ ${?} -eq 0 ]
  42. then
  43. printf "%s\n" "::: travelmate runtime information"
  44. json_get_keys keylist
  45. for key in ${keylist}
  46. do
  47. json_get_var value "${key}"
  48. printf " + %-18s : %s\n" "${key}" "${value}"
  49. done
  50. else
  51. printf "%s\n" "::: no travelmate runtime information available"
  52. fi
  53. }
  54. service_triggers()
  55. {
  56. local trigger="$(uci_get travelmate global trm_iface)"
  57. local delay="$(uci_get travelmate global trm_triggerdelay)"
  58. PROCD_RELOAD_DELAY=$((${delay:-2} * 1000))
  59. procd_add_interface_trigger "interface.*.down" "${trigger}" "${trm_init}" reload
  60. procd_add_reload_trigger "travelmate"
  61. }