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.

86 lines
2.2 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 legacy=$( uci_get unbound.@unbound[0].trigger )
  46. local triggers=$( uci_get unbound.@unbound[0].trigger_interface )
  47. local trigger="$triggers $legacy"
  48. . /usr/lib/unbound/defaults.sh
  49. if [ ! -f "$UB_TOTAL_CONF" -o -n "$UB_BOOT" ] ; then
  50. # Unbound is can be a bit heavy, so wait some on first start but any
  51. # interface coming up affects the trigger and delay so guarantee start
  52. procd_add_raw_trigger "interface.*.up" 5000 /etc/init.d/unbound restart
  53. elif [ -n "$triggers" ] ; then
  54. PROCD_RELOAD_DELAY=2000
  55. procd_add_reload_trigger "unbound" "dhcp"
  56. for trigger in $triggers ; do
  57. # User selected triggers to restart at any other time
  58. procd_add_reload_interface_trigger "$trigger"
  59. done
  60. else
  61. PROCD_RELOAD_DELAY=2000
  62. procd_add_reload_trigger "unbound" "dhcp"
  63. fi
  64. }
  65. ##############################################################################