On 2014-05-27 Tue 14:13 PM |, Martin, Matthew wrote:
> I'm moving to unbound in preparation for 5.6. Trying to start unbound
> on boot with pkg_scripts would always fail; however, starting it
> manually would succeed. This seems to be because /etc/rc does not have
> /usr/local/sbin in it's PATH and /etc/rc.d/unbound calls
> unbound-control-setup.
> 

I'm using this with the packaged unbound-1.4.20 on 5.4 RELEASE:

#!/bin/sh
#

_sbin='/usr/local/sbin'
_chroot='/var/unbound'
_etc="${_chroot}/etc"
_config="${_etc}/unbound.conf"
daemon="${_sbin}/unbound"
daemon_flags="-c ${_config}"

. /etc/rc.d/rc.subr

pexp="unbound${daemon_flags:+ ${daemon_flags}}"
rc_reload=NO

rc_pre() {
        if grep '^[[:space:]]*control-enable:[[:space:]]*yes' \
            ${_config} > /dev/null 2>&1 && \
            ! [[ -f ${_etc}/unbound_server.key ||
            -f ${_etc}/unbound_server.pem ||
            -f ${_etc}/unbound_control.key ||
            -f ${_etc}/unbound_control.pem ]]; then
                ${_sbin}/unbound-control-setup 2> /dev/null
        fi
        if grep '^[[:space:]]*auto-trust-anchor-file:' \
            ${_config} > /dev/null 2>&1; then
                ${_sbin}/unbound-anchor -v -a "${_chroot}/db/root.key" || true
        fi
}

rc_start() {
        ${_sbin}/unbound-checkconf > /dev/null &&
            ${rcexec} "unbound ${daemon_flags}"
}

rc_cmd $1

Reply via email to