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.

70 lines
1.3 KiB

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