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.

77 lines
1.9 KiB

  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. boot() {
  17. UB_BOOT=1
  18. start "$@"
  19. }
  20. ##############################################################################
  21. start_service() {
  22. if [ -n "$UB_BOOT" ] ; then
  23. # Load procd triggers (rc) and use event IFUP to really start
  24. return 0
  25. fi
  26. # complex UCI work
  27. . /usr/lib/unbound/unbound.sh
  28. unbound_start
  29. # standard procd clause
  30. procd_open_instance "unbound"
  31. procd_set_param command $PROG -d -c $UB_TOTAL_CONF
  32. procd_set_param respawn
  33. procd_close_instance
  34. }
  35. ##############################################################################
  36. stop_service() {
  37. # clean up
  38. . /usr/lib/unbound/stopping.sh
  39. unbound_stop
  40. # Wait! on restart Unbound may take time writing closure stats to syslog
  41. pidof $PROG && sleep 1
  42. }
  43. ##############################################################################
  44. service_triggers() {
  45. local trigger
  46. local legacy=$( uci_get unbound.@unbound[0].trigger )
  47. local triggers=$( uci_get unbound.@unbound[0].trigger_interface )
  48. triggers="$triggers $legacy"
  49. PROCD_RELOAD_DELAY=2000
  50. procd_add_reload_trigger "unbound"
  51. if [ -n "$triggers" ] ; then
  52. for trigger in $triggers ; do
  53. # due to some netifd/procd interactions with IP6, limit interfaces
  54. procd_add_reload_interface_trigger "$trigger"
  55. done
  56. else
  57. procd_add_raw_trigger "interface.*.up" 2000 /etc/init.d/unbound reload
  58. fi
  59. }
  60. ##############################################################################