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

%config
    knot_enable="$openpkg_rc_def"
    knot_flags=""
    knot_log_prolog="true"
    knot_log_epilog="true"
    knot_log_numfiles="10"
    knot_log_minsize="1M"
    knot_log_complevel="9"

%status -u @l_susr@ -o
    knot_usable="no"
    knot_active="no"
    @l_prefix@/sbin/knotc checkconf >/dev/null 2>&1 && knot_usable=yes
    @l_prefix@/sbin/knotc running   >/dev/null 2>&1 && knot_active=yes
    echo "knot_enable=\"$knot_enable\""
    echo "knot_usable=\"$knot_usable\""
    echo "knot_active=\"$knot_active\""

%start -u @l_susr@
    rcService knot enable yes || exit 0
    rcService knot active yes && exit 0
    @l_prefix@/sbin/knotc start

%stop -u @l_susr@
    rcService knot enable yes || exit 0
    rcService knot active no  && exit 0
    @l_prefix@/sbin/knotc stop
    sleep 2

%restart -u @l_susr@
    rcService knot enable yes || exit 0
    rcService knot active no  && exit 0
    @l_prefix@/sbin/knotc restart

%reload -u @l_susr@
    rcService knot enable yes || exit 0
    rcService knot active no  && exit 0
    @l_prefix@/sbin/knotc reload

%daily -u @l_susr@
    rcService knot enable yes || exit 0
    shtool rotate -f \
        -n $knot_stats_numfiles -s $knot_stats_minsize -d \
        -z $knot_stats_complevel -m 644 -o @l_rusr@ -g @l_rgrp@ \
        -P "$knot_stats_prolog" \
        -E "$knot_stats_epilog" \
        @l_prefix@/var/knot/log/knot.log

