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

%config
    pound_enable="$openpkg_rc_def"
    pound_log_prolog="true"
    pound_log_epilog="true"
    pound_log_numfiles="10"
    pound_log_minsize="1M"
    pound_log_complevel="9"

%common
    pound_pidfile="@l_prefix@/var/pound/pound.pid"
    pound_signal () {
        [ -f $pound_pidfile ] && kill -$1 `cat $pound_pidfile`
    }

%status -u @l_susr@ -o
    pound_usable="unknown"
    pound_active="no"
    rcService pound enable yes && \
        pound_signal 0 && pound_active="yes"
    echo "pound_enable=\"$pound_enable\""
    echo "pound_usable=\"$pound_usable\""
    echo "pound_active=\"$pound_active\""

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

%stop -u @l_susr@
    rcService pound enable yes || exit 0
    rcService pound active no && exit 0
    pound_signal TERM
    sleep 1

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

%daily -u @l_susr@
    rcService pound enable yes || exit 0
    shtool rotate -f \
        -n ${pound_log_numfiles} -s ${pound_log_minsize} -d \
        -z ${pound_log_complevel} -o @l_rusr@ -g @l_rgrp@ -m 644 \
        -P "${pound_log_prolog}" \
        -E "${pound_log_epilog}" \
        @l_prefix@/var/pound/pound.log

