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.

89 lines
1.7 KiB

  1. #!/bin/sh /etc/rc.common
  2. #
  3. START=30
  4. USE_PROCD=1
  5. EXTRA_COMMANDS="suspend resume query status"
  6. EXTRA_HELP=" suspend Suspend adblock processing
  7. resume Resume adblock processing
  8. query <DOMAIN> Query active blocklists for specific domains
  9. status Print runtime information"
  10. adb_init="/etc/init.d/adblock"
  11. adb_script="/usr/bin/adblock.sh"
  12. boot()
  13. {
  14. adb_boot=1
  15. rc_procd start_service
  16. }
  17. start_service()
  18. {
  19. if [ $("${adb_init}" enabled; printf "%u" ${?}) -eq 0 ]
  20. then
  21. if [ -n "${adb_boot}" ]
  22. then
  23. local trigger="$(uci_get adblock.global.adb_trigger)"
  24. if [ "${trigger}" != "timed" ]
  25. then
  26. return 0
  27. fi
  28. fi
  29. procd_open_instance "adblock"
  30. procd_set_param command "${adb_script}" "${@}"
  31. procd_set_param stdout 1
  32. procd_set_param stderr 1
  33. procd_close_instance
  34. fi
  35. }
  36. reload_service()
  37. {
  38. rc_procd start_service reload
  39. }
  40. stop_service()
  41. {
  42. rc_procd "${adb_script}" stop
  43. rc_procd start_service
  44. }
  45. restart()
  46. {
  47. rc_procd start_service restart
  48. }
  49. suspend()
  50. {
  51. rc_procd "${adb_script}" suspend
  52. }
  53. resume()
  54. {
  55. rc_procd "${adb_script}" resume
  56. }
  57. query()
  58. {
  59. rc_procd "${adb_script}" query "${1}"
  60. }
  61. status()
  62. {
  63. rc_procd "${adb_script}" status
  64. }
  65. service_triggers()
  66. {
  67. local trigger="$(uci_get adblock.global.adb_trigger)"
  68. local delay="$(uci_get adblock.global.adb_triggerdelay)"
  69. if [ "${trigger}" != "none" ] && [ "${trigger}" != "timed" ]
  70. then
  71. PROCD_RELOAD_DELAY=$((${delay:=1} * 1000))
  72. procd_add_interface_trigger "interface.*.up" "${trigger}" "${adb_init}" start
  73. fi
  74. procd_add_reload_trigger "adblock"
  75. }