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.

75 lines
1.3 KiB

  1. #!/bin/sh /etc/rc.common
  2. #
  3. START=99
  4. exec 2>/dev/null
  5. adb_pid="${$}"
  6. adb_script="/usr/bin/adblock-update.sh"
  7. adb_pidfile="/var/run/adblock.pid"
  8. adb_logger="/usr/bin/logger"
  9. if [ -t 1 ]
  10. then
  11. log_parm="-s"
  12. unset bg_parm
  13. else
  14. unset log_parm
  15. bg_parm="&"
  16. fi
  17. if [ -r "${adb_pidfile}" ]
  18. then
  19. "${adb_logger}" ${log_parm} -t "adblock[${adb_pid}] error" "adblock service already running ($(cat ${adb_pidfile})" 2>&1
  20. exit 255
  21. fi
  22. boot()
  23. {
  24. return 0
  25. }
  26. start()
  27. {
  28. eval "${adb_script}" ${bg_parm}
  29. return 0
  30. }
  31. restart()
  32. {
  33. stop
  34. start
  35. }
  36. reload()
  37. {
  38. stop
  39. start
  40. }
  41. stop()
  42. {
  43. rm_done="$(find "/tmp/dnsmasq.d" -maxdepth 1 -type f -name "adb_list.*" -print -exec rm -f "{}" \;)"
  44. rc=${?}
  45. if [ $((rc)) -eq 0 ] && [ -n "${rm_done}" ]
  46. then
  47. . "/usr/bin/adblock-helper.sh"
  48. uci_remove "adblock" "global" "adb_overall_count"
  49. f_rmconfig "${rm_done}"
  50. uci_commit "adblock"
  51. /etc/init.d/dnsmasq restart
  52. /etc/init.d/firewall restart
  53. fi
  54. uhttpd_pid="$(ps | grep "[u]httpd.*\-h /www/adblock" | awk '{print $1}')"
  55. if [ -n "${uhttpd_pid}" ]
  56. then
  57. kill -9 "${uhttpd_pid}"
  58. fi
  59. if [ -n "${rm_done}" ] || [ -n "${uhttpd_pid}" ]
  60. then
  61. "${adb_logger}" ${log_parm} -t "adblock[${adb_pid}] info " "all adblock related services stopped" 2>&1
  62. fi
  63. return 0
  64. }