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

%config
    conman_enable="$openpkg_rc_def"
    conman_log_prolog="true"
    conman_log_epilog="true"
    conman_log_numfiles="10"
    conman_log_minsize="1M"
    conman_log_complevel="9"

%common
    conman_logfile="@l_prefix@/var/conman/log/conmand.log"
    conman_signal () {
        kill -$1 `@l_prefix@/sbin/conmand -q`
    }

%status -u @l_susr@ -o
    conman_usable="unknown"
    conman_active="no"
    rcService conman enable yes && \
        conman_signal 0 && conman_active="yes"
    echo "conman_enable=\"$conman_enable\""
    echo "conman_usable=\"$conman_usable\""
    echo "conman_active=\"$conman_active\""

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

%stop -u @l_susr@
    rcService conman enable yes || exit 0
    rcService conman active no  && exit 0
    @l_prefix@/sbin/conmand -k

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

%reload -u @l_susr@
    rcService conman enable yes || exit 0
    rcService conman active no  && exit 0
    @l_prefix@/sbin/conmand -r

%daily -u @l_susr@
    rcService conman enable yes || exit 0
    shtool rotate -f \
        -n ${conman_log_numfiles} -s ${conman_log_minsize} -d \
        -z ${conman_log_complevel} -m 664 -o @l_rusr@ -g @l_rgrp@ \
        -P "${conman_log_prolog}" \
        -E "${conman_log_epilog}; rc conman reload" \
        $conman_logfile
    for logfile in @l_prefix@/var/conman/log/console-*.log; do
        shtool rotate -f \
            -n ${conman_log_numfiles} -s ${conman_log_minsize} -d \
            -z ${conman_log_complevel} -m 664 -o @l_rusr@ -g @l_rgrp@ \
            -P "${conman_log_prolog}" \
            -E "${conman_log_epilog}; rc conman reload" \
            $logfile
    done

