#!@l_prefix@/bin/openpkg rc
##
##  rc.nsd -- Run-Commands
##

%config
    nsd_enable="$openpkg_rc_def"
    nsd_log_prolog="true"
    nsd_log_epilog="true"
    nsd_log_numfiles="10"
    nsd_log_minsize="1M"
    nsd_log_complevel="9"

%status -p 100 -u @l_susr@ -o
    nsd_usable="unknown"
    nsd_active="no"
    @l_prefix@/sbin/nsdc running >/dev/null && nsd_active="yes"
    echo "nsd_enable=\"$nsd_enable\""
    echo "nsd_usable=\"$nsd_usable\""
    echo "nsd_active=\"$nsd_active\""

%start -p 100 -u @l_susr@
    rcService nsd enable yes || exit 0
    rcService nsd active yes && exit 0
    @l_prefix@/sbin/nsdc start

%stop -p 900 -u @l_susr@
    rcService nsd enable yes || exit 0
    rcService nsd active no && exit 0
    @l_prefix@/sbin/nsdc stop

%reload -p 100 -u @l_susr@
    rcService nsd enable yes || exit 0
    rcService nsd active no && exit 0
    @l_prefix@/sbin/nsdc reload

%daily -u @l_rusr@
    rcService nsd enable yes || exit 0
    shtool rotate -f \
        -n ${nsd_log_numfiles} -s ${nsd_log_minsize} -d \
        -z ${nsd_log_complevel} -o @l_rusr@ -g @l_rgrp@ -m 644 \
        -P "${nsd_log_prolog}" \
        -E "${nsd_log_epilog}" \
        @l_prefix@/var/nsd/nsd.log

