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.

71 lines
1.2 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. /etc/init.d/dnsmasq restart
  48. /etc/init.d/firewall restart
  49. fi
  50. uhttpd_pid="$(ps | grep "[u]httpd.*\-h /www/adblock" | awk '{print $1}')"
  51. if [ -n "${uhttpd_pid}" ]
  52. then
  53. kill -9 "${uhttpd_pid}"
  54. fi
  55. if [ -n "${rm_done}" ] || [ -n "${uhttpd_pid}" ]
  56. then
  57. "${adb_logger}" ${log_parm} -t "adblock[${adb_pid}] info " "all adblock related services stopped" 2>&1
  58. fi
  59. return 0
  60. }