#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
##
##  rc.qpopper -- Run-Commands for QPopper Daemon
##

%config
    qpopper_enable="yes"
    qpopper_bind="127.0.0.1:110"
    qpopper_log_prolog="true"
    qpopper_log_epilog="true"
    qpopper_log_numfiles="10"
    qpopper_log_minsize="1M"
    qpopper_log_complevel="9"
    pop_type="qpopper"
    pop_logfile="@l_prefix@/var/qpopper/qpopper.log"

%start -p 200 -u root
    opServiceEnabled qpopper || exit 0
    @l_prefix@/sbin/qpopper ${qpopper_bind} -S -f @l_prefix@/etc/qpopper/qpopper.config

%stop -p 200 -u root
    opServiceEnabled qpopper || exit 0
    if [ -f @l_prefix@/var/qpopper/qpopper.pid ]; then
        kill -TERM `cat @l_prefix@/var/qpopper/qpopper.pid`
        rm -f @l_prefix@/var/qpopper/qpopper.pid >/dev/null 2>&1 || true
    fi

%restart -u root
    opServiceEnabled qpopper || exit 0
    if [ -f @l_prefix@/var/qpopper/qpopper.pid ]; then
        kill -TERM `cat @l_prefix@/var/qpopper/qpopper.pid`
        rm -f @l_prefix@/var/qpopper/qpopper.pid >/dev/null 2>&1 || true
        sleep 2
    fi
    @l_prefix@/sbin/qpopper ${qpopper_bind} -S -f @l_prefix@/etc/qpopper/qpopper.config

%daily -u root
    opServiceEnabled qpopper || exit 0
    shtool rotate -f \
        -n${qpopper_log_numfiles} -s${qpopper_log_minsize} -d \
        -z${qpopper_log_complevel} -o@l_musr@ -g@l_mgrp@ -m644 \
        -P "${qpopper_log_prolog}" \
        -E "${qpopper_log_epilog}" \
        $pop_logfile

