2014-08-17 18:39:56 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
2016-10-20 04:17:23 +00:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Copyright (C) 2016 Michael Hanselmann, Eric Luehrsen
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# This init script is just the entry point for Unbound UCI.
|
|
|
|
#
|
|
|
|
##############################################################################
|
2014-08-17 18:39:56 +00:00
|
|
|
|
2017-03-25 05:53:28 +00:00
|
|
|
START=19
|
|
|
|
STOP=50
|
2016-06-10 20:46:08 +00:00
|
|
|
USE_PROCD=1
|
2016-10-20 04:17:23 +00:00
|
|
|
PROG=/usr/sbin/unbound
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
|
2017-03-25 05:53:28 +00:00
|
|
|
boot() {
|
2018-06-29 00:41:37 +00:00
|
|
|
UB_BOOT=1
|
2017-03-25 05:53:28 +00:00
|
|
|
start "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
|
2016-06-10 20:46:08 +00:00
|
|
|
start_service() {
|
2018-06-29 00:41:37 +00:00
|
|
|
if [ -n "$UB_BOOT" ] ; then
|
2017-03-25 05:53:28 +00:00
|
|
|
# Load procd triggers (rc) and use event IFUP to really start
|
|
|
|
return 0
|
|
|
|
fi
|
2017-03-18 02:45:47 +00:00
|
|
|
|
2016-12-29 06:32:31 +00:00
|
|
|
# complex UCI work
|
2018-06-26 00:40:21 +00:00
|
|
|
. /usr/lib/unbound/unbound.sh
|
2016-12-29 06:32:31 +00:00
|
|
|
unbound_start
|
2016-06-10 20:46:28 +00:00
|
|
|
|
2016-12-29 06:32:31 +00:00
|
|
|
# standard procd clause
|
2018-06-26 00:40:21 +00:00
|
|
|
procd_open_instance "unbound"
|
2018-06-29 00:41:37 +00:00
|
|
|
procd_set_param command $PROG -d -c $UB_TOTAL_CONF
|
2016-10-20 04:17:23 +00:00
|
|
|
procd_set_param respawn
|
|
|
|
procd_close_instance
|
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
2016-06-10 20:46:28 +00:00
|
|
|
|
2016-10-20 04:17:23 +00:00
|
|
|
stop_service() {
|
2018-06-26 00:40:21 +00:00
|
|
|
# clean up
|
2018-06-29 00:41:37 +00:00
|
|
|
. /usr/lib/unbound/stopping.sh
|
2016-12-29 06:32:31 +00:00
|
|
|
unbound_stop
|
2017-05-10 02:46:39 +00:00
|
|
|
|
2017-03-25 05:53:28 +00:00
|
|
|
# Wait! on restart Unbound may take time writing closure stats to syslog
|
|
|
|
pidof $PROG && sleep 1
|
2014-08-17 18:39:56 +00:00
|
|
|
}
|
2016-10-20 04:17:23 +00:00
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
|
2016-10-28 02:04:00 +00:00
|
|
|
service_triggers() {
|
2018-02-13 05:01:58 +00:00
|
|
|
local legacy=$( uci_get unbound.@unbound[0].trigger )
|
|
|
|
local triggers=$( uci_get unbound.@unbound[0].trigger_interface )
|
2018-08-01 02:59:24 +00:00
|
|
|
local trigger="$triggers $legacy"
|
2017-05-10 02:46:39 +00:00
|
|
|
|
2018-08-01 02:59:24 +00:00
|
|
|
. /usr/lib/unbound/defaults.sh
|
|
|
|
|
|
|
|
|
2019-05-14 02:54:07 +00:00
|
|
|
if [ ! -f "$UB_TOTAL_CONF" ] || [ -n "$UB_BOOT" ] ; then
|
2019-06-02 18:14:23 +00:00
|
|
|
# Unbound can be a bit heavy, so wait some on first start. Any interface
|
|
|
|
# up affects the trigger delay and will guarantee start.
|
2018-08-09 01:21:17 +00:00
|
|
|
procd_add_raw_trigger "interface.*.up" 3000 /etc/init.d/unbound restart
|
2018-08-01 02:59:24 +00:00
|
|
|
|
|
|
|
elif [ -n "$triggers" ] ; then
|
|
|
|
procd_add_reload_trigger "unbound" "dhcp"
|
2017-05-10 02:46:39 +00:00
|
|
|
|
2018-02-13 05:01:58 +00:00
|
|
|
|
2017-05-10 02:46:39 +00:00
|
|
|
for trigger in $triggers ; do
|
2018-08-01 02:59:24 +00:00
|
|
|
# User selected triggers to restart at any other time
|
2017-05-10 02:46:39 +00:00
|
|
|
procd_add_reload_interface_trigger "$trigger"
|
|
|
|
done
|
2018-08-01 02:59:24 +00:00
|
|
|
|
2017-05-10 02:46:39 +00:00
|
|
|
else
|
2018-08-01 02:59:24 +00:00
|
|
|
procd_add_reload_trigger "unbound" "dhcp"
|
2017-05-10 02:46:39 +00:00
|
|
|
fi
|
2016-10-28 02:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
|