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.

58 lines
1.3 KiB

  1. #!/bin/sh /etc/rc.common
  2. START=90
  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. boot()
  9. {
  10. ubus -t 30 wait_for network.interface network.wireless 2>/dev/null
  11. rc_procd start_service
  12. }
  13. start_service()
  14. {
  15. if [ $("${trm_init}" enabled; printf "%u" ${?}) -eq 0 ]
  16. then
  17. procd_open_instance "travelmate"
  18. procd_set_param command "${trm_script}" "${@}"
  19. procd_set_param stdout 1
  20. procd_set_param stderr 1
  21. procd_close_instance
  22. fi
  23. }
  24. stop_service()
  25. {
  26. local rtfile="$(uci -q get travelmate.global.trm_rtfile)"
  27. rtfile="${rtfile:="/tmp/trm_runtime.json"}"
  28. > "${rtfile}"
  29. rc_procd start_service
  30. }
  31. status()
  32. {
  33. rc_procd "${trm_script}" status
  34. }
  35. service_triggers()
  36. {
  37. local auto="$(uci -q get travelmate.global.trm_automatic)"
  38. if [ "${auto}" = "0" ]
  39. then
  40. local iface="$(uci -q get travelmate.global.trm_iface)"
  41. local delay="$(uci -q get travelmate.global.trm_triggerdelay)"
  42. PROCD_RELOAD_DELAY=$((${delay:=2} * 1000))
  43. procd_add_interface_trigger "interface.*.down" "${iface}" "${trm_init}" start
  44. fi
  45. PROCD_RELOAD_DELAY=1000
  46. procd_add_config_trigger "config.change" "travelmate" "${trm_init}" start
  47. }