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

%config
    siproxd_enable="$openpkg_rc_def"
    siproxd_flags=""
    siproxd_log_prolog="true"
    siproxd_log_epilog="true"
    siproxd_log_numfiles="10"
    siproxd_log_minsize="1M"
    siproxd_log_complevel="9"

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

%status -u @l_susr@ -o
    siproxd_usable="no"
    siproxd_active="no"
    rcService siproxd enable yes && \
        siproxd_signal 0 && siproxd_active="yes"
    echo "siproxd_enable=\"$siproxd_enable\""
    echo "siproxd_usable=\"$siproxd_usable\""
    echo "siproxd_active=\"$siproxd_active\""

%start -p 100 -u @l_susr@
    rcService siproxd enable yes || exit 0
    rcService siproxd active yes && exit 0
    @l_prefix@/sbin/siproxd ${siproxd_flags}

%stop -p 900 -u @l_susr@
    rcService siproxd enable yes || exit 0
    rcService siproxd active no  && exit 0
    siproxd_signal TERM
    sleep 2
    rm -f $siproxd_pidfile >/dev/null 2>&1 || true

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

%daily -u @l_susr@
    rcService siproxd enable yes || exit 0
    shtool rotate -f \
        -n ${siproxd_log_numfiles} -s ${siproxd_log_minsize} -d \
        -z ${siproxd_log_complevel} -m 644 -o @l_rusr@ -g @l_rgrp@ \
        -P "${siproxd_log_prolog}" \
        -E "${siproxd_log_epilog}; rc siproxd restart" \
        @l_prefix@/var/siproxd/siproxd.log

