unbound.init 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh /etc/rc.common
  2. ##############################################################################
  3. #
  4. # Copyright (C) 2016 Michael Hanselmann, Eric Luehrsen
  5. #
  6. ##############################################################################
  7. #
  8. # This init script is just the entry point for Unbound UCI.
  9. #
  10. ##############################################################################
  11. START=19
  12. STOP=50
  13. USE_PROCD=1
  14. PROG=/usr/sbin/unbound
  15. ##############################################################################
  16. . /usr/lib/unbound/unbound.sh
  17. ##############################################################################
  18. boot() {
  19. UNBOUND_BOOT=1
  20. start "$@"
  21. }
  22. ##############################################################################
  23. start_service() {
  24. if [ -n "$UNBOUND_BOOT" ] ; then
  25. # Load procd triggers (rc) and use event IFUP to really start
  26. return 0
  27. fi
  28. # complex UCI work
  29. unbound_start
  30. # standard procd clause
  31. procd_open_instance
  32. procd_set_param command $PROG -d -c $UNBOUND_CONFFILE
  33. procd_set_param respawn
  34. procd_close_instance
  35. }
  36. ##############################################################################
  37. stop_service() {
  38. unbound_stop
  39. # Wait! on restart Unbound may take time writing closure stats to syslog
  40. pidof $PROG && sleep 1
  41. }
  42. ##############################################################################
  43. service_triggers() {
  44. # use soft reload to prevent continuous stop-start and cache flush
  45. procd_add_reload_trigger "unbound"
  46. procd_add_raw_trigger "interface.*.up" 2000 /etc/init.d/unbound reload
  47. }
  48. ##############################################################################