#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:          opendnssec-signer
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: OpenDNSSEC Signer
# Description:       Daemon to periodically sign DNSSEC zone files.
### END INIT INFO

NAME=opendnsec-signer
DAEMON=/usr/sbin/ods-signerd
DESC="OpenDNSSEC Signer"
PIDFILE=/run/opendnssec/signerd.pid

do_tmpfiles() {
    local type path mode user group

    TMPFILES=/usr/lib/tmpfiles.d/$1.conf

    if [ -r "$TMPFILES" ]; then
	while read type path mode user group; do
            if [ "$type" = "d" ]; then
                mkdir -p "$path"
		chmod "$mode" "$path"
                chown "$user:$group" "$path"
            fi
        done
    fi
}

do_start_prepare() {
    do_tmpfiles $(basename $0)
    DAEMON_ARGS="$DAEMON_ARGS $ODS_SIGNERD_OPT"
}
