1 #!/bin/sh /etc/rc.common
2 ##############################################################################
4 # Copyright (C) 2016 Michael Hanselmann, Eric Luehrsen
6 ##############################################################################
8 # This init script is just the entry point for Unbound UCI.
10 ##############################################################################
15 PROG=/usr/sbin/unbound
17 ##############################################################################
24 ##############################################################################
27 if [ -n "$UB_BOOT" ] ; then
28 # Load procd triggers (rc) and use event IFUP to really start
33 . /usr/lib/unbound/unbound.sh
36 # standard procd clause
37 procd_open_instance "unbound"
38 procd_set_param command $PROG -d -c $UB_TOTAL_CONF
39 procd_set_param respawn
43 ##############################################################################
47 . /usr/lib/unbound/stopping.sh
50 # Wait! on restart Unbound may take time writing closure stats to syslog
51 pidof $PROG && sleep 1
54 ##############################################################################
57 local legacy=$( uci_get unbound.@unbound[0].trigger )
58 local triggers=$( uci_get unbound.@unbound[0].trigger_interface )
59 local trigger="$triggers $legacy"
61 . /usr/lib/unbound/defaults.sh
64 if [ ! -f "$UB_TOTAL_CONF" -o -n "$UB_BOOT" ] ; then
65 # Unbound is can be a bit heavy, so wait some on first start but any
66 # interface coming up affects the trigger and delay so guarantee start
67 procd_add_raw_trigger "interface.*.up" 3000 /etc/init.d/unbound restart
69 elif [ -n "$triggers" ] ; then
70 procd_add_reload_trigger "unbound" "dhcp"
73 for trigger in $triggers ; do
74 # User selected triggers to restart at any other time
75 procd_add_reload_interface_trigger "$trigger"
79 procd_add_reload_trigger "unbound" "dhcp"
83 ##############################################################################