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" ] ||
[ -n "$UB_BOOT" ] ; then
65 # Unbound can be a bit heavy, so wait some on first start. Any interface
66 # up affects the trigger delay and will guarantee start.
67 procd_add_raw_trigger
"interface.*.up" 3000 /etc
/init.d
/unbound restart
69 elif [ -n "$triggers" ] ; then
70 for trigger
in $triggers ; do
71 # User selected triggers to restart at any other time
72 procd_add_reload_interface_trigger
"$trigger"
75 procd_add_reload_trigger
"unbound" "dhcp"
78 procd_add_reload_trigger
"unbound" "dhcp"
82 ##############################################################################