#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
##
##  rc.teapop -- Run-Commands for Teapop POP3-Server
##

%config
    teapop_enable="yes"
    teapop_log_prolog="true"
    teapop_log_epilog="true"
    teapop_log_numfiles="10"
    teapop_log_minsize="1M"
    teapop_log_complevel="9"
    pop_type="teapop"
    pop_logfile="@l_prefix@/var/teapop/teapop.log"

%start -p 200 -u root
    opServiceEnabled teapop || exit 0
    @l_prefix@/sbin/teapop -s

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

%restart -u root
    opServiceEnabled teapop || exit 0
    if [ -f @l_prefix@/var/teapop/teapop.pid ]; then
        kill -TERM `cat @l_prefix@/var/teapop/teapop.pid`
        rm -f @l_prefix@/var/teapop/teapop.pid >/dev/null 2>&1 || true
        sleep 2
    fi
    @l_prefix@/sbin/teapop -s

%daily -u root
    opServiceEnabled teapop || exit 0
    shtool rotate -f \
        -n${teapop_log_numfiles} -s${teapop_log_minsize} -d \
        -z${teapop_log_complevel} -o@l_susr@ -g@l_sgrp@ -m600 \
        -P "${teapop_log_prolog}" \
        -E "@l_prefix@/etc/rc.d/rc.teapop restart; ${teapop_log_epilog}" \
        $pop_logfile

