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

%config
    bind_enable="$openpkg_rc_def"
    bind_flags=""
    bind_log_prolog="true"
    bind_log_epilog="true"
    bind_log_numfiles="10"
    bind_log_minsize="1M"
    bind_log_complevel="9"
    bind_stats_prolog="true"
    bind_stats_epilog="true"
    bind_stats_numfiles="10"
    bind_stats_minsize="1M"
    bind_stats_complevel="9"

%status -u @l_susr@ -o
    bind_usable="no"
    bind_active="no"
    @l_prefix@/sbin/named-checkconf >/dev/null && bind_usable="yes"
    @l_prefix@/sbin/rndc status >/dev/null 2>&1 && bind_active="yes"
    echo "bind_enable=\"$bind_enable\""
    echo "bind_usable=\"$bind_usable\""
    echo "bind_active=\"$bind_active\""

%start -p 100 -u @l_susr@
    rcService bind enable yes || exit 0
    rcService bind active yes && exit 0
    @l_prefix@/sbin/named -u @l_rusr@ ${bind_flags}

%stop -p 900 -u @l_susr@
    rcService bind enable yes || exit 0
    rcService bind active no  && exit 0
    @l_prefix@/sbin/rndc stop
    sleep 2

%restart -p 100 -u @l_susr@
    rcService bind enable yes || exit 0
    rcService bind active no  && exit 0
    rc bind stop start

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

%daily -u @l_susr@
    rcService bind enable yes || exit 0
    shtool rotate -f \
        -n $bind_stats_numfiles -s $bind_stats_minsize -d \
        -z $bind_stats_complevel -m 644 -o @l_rusr@ -g @l_rgrp@ \
        -P "$bind_stats_prolog" \
        -E "$bind_stats_epilog" \
        @l_prefix@/var/bind/named.stats
    shtool rotate -f \
        -n $bind_log_numfiles -s $bind_log_minsize -d \
        -z $bind_log_complevel -m 644 -o @l_rusr@ -g @l_rgrp@ \
        -P "$bind_log_prolog" \
        -E "$bind_log_epilog; rc bind reload" \
        @l_prefix@/var/bind/named.log

