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.

56 lines
1.2 KiB

  1. #!/bin/sh /etc/rc.common
  2. START=35
  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 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 iface="$(uci -q get travelmate.global.trm_iface)"
  38. local delay="$(uci -q get travelmate.global.trm_triggerdelay)"
  39. PROCD_RELOAD_DELAY=$((${delay:=2} * 1000))
  40. for name in ${iface}
  41. do
  42. procd_add_interface_trigger "interface.*.down" "${name}" "${trm_init}" start
  43. done
  44. PROCD_RELOAD_DELAY=1000
  45. procd_add_config_trigger "config.change" "travelmate" "${trm_init}" start
  46. }