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.3 KiB

  1. #!/bin/sh /etc/rc.common
  2. #
  3. START=90
  4. USE_PROCD=1
  5. EXTRA_COMMANDS="suspend resume query"
  6. EXTRA_HELP=" suspend Suspend adblock processing
  7. resume Resume adblock processing
  8. query <DOMAIN> Query active blocklists for specific domain"
  9. adb_init="/etc/init.d/adblock"
  10. adb_script="/usr/bin/adblock.sh"
  11. boot()
  12. {
  13. local list iface="$(uci -q get adblock.global.adb_iface)"
  14. for name in ${iface}
  15. do
  16. list="${list} network.interface.${name}"
  17. done
  18. ubus -t 60 wait_for network.interface ${list} 2>/dev/null
  19. rc_procd start_service
  20. }
  21. start_service()
  22. {
  23. if [ $("${adb_init}" enabled; printf ${?}) -eq 0 ]
  24. then
  25. procd_open_instance "adblock"
  26. procd_set_param command "${adb_script}" "${@}"
  27. procd_set_param stdout 1
  28. procd_set_param stderr 1
  29. procd_close_instance
  30. fi
  31. }
  32. stop_service()
  33. {
  34. rc_procd "${adb_script}" stop
  35. }
  36. restart()
  37. {
  38. rc_procd start_service restart
  39. }
  40. suspend()
  41. {
  42. rc_procd "${adb_script}" suspend
  43. }
  44. resume()
  45. {
  46. rc_procd "${adb_script}" resume
  47. }
  48. query()
  49. {
  50. rc_procd "${adb_script}" query "${1}"
  51. }
  52. service_triggers()
  53. {
  54. local iface="$(uci -q get adblock.global.adb_iface)"
  55. for name in ${iface}
  56. do
  57. procd_add_interface_trigger "interface.*.up" "${name}" "${adb_init}" start
  58. done
  59. procd_add_config_trigger "config.change" "adblock" "${adb_init}" start
  60. }