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

%config
    ocspd_enable="$openpkg_rc_def"
    ocspd_log_prolog="true"
    ocspd_log_epilog="true"
    ocspd_log_numfiles="10"
    ocspd_log_minsize="1M"
    ocspd_log_complevel="9"

%common
    ocspd_cfgfile="@l_prefix@/etc/ocspd/ocspd.xml"
    ocspd_pidfile="@l_prefix@/var/ocspd/run/ocspd.pid"
    ocspd_logfile="@l_prefix@/var/ocspd/log/ocspd.log"
    ocspd_signal () {
        [ -f $ocspd_pidfile ] && kill -$1 `cat $ocspd_pidfile`
    }

%status -u @l_rusr@ -o
    ocspd_usable="unknown"
    ocspd_active="no"
    rcService ocspd enable yes && \
        ocspd_signal 0 && ocspd_active="yes"
    echo "ocspd_enable=\"$ocspd_enable\""
    echo "ocspd_usable=\"$ocspd_usable\""
    echo "ocspd_active=\"$ocspd_active\""

%start -u @l_rusr@
    rcService ocspd enable yes || exit 0
    rcService ocspd active yes && exit 0
    @l_prefix@/sbin/ocspd -d -c $ocspd_cfgfile

%stop -u @l_rusr@
    rcService ocspd enable yes || exit 0
    rcService ocspd active no  && exit 0
    ocspd_signal TERM
    sleep 2
    rm -f $ocspd_pidfile >/dev/null 2>&1 || true

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

%reload -u @l_rusr@
    rcService ocspd enable yes || exit 0
    rcService ocspd active no  && exit 0
    ocspd_signal HUP

%daily -u @l_susr@
    rcService ocspd enable yes || exit 0
    shtool rotate -f \
        -n ${ocspd_log_numfiles} -s ${ocspd_log_minsize} -d \
        -z ${ocspd_log_complevel} -m 664 -o @l_rusr@ -g @l_rgrp@ \
        -P "${ocspd_log_prolog}" \
        -E "${ocspd_log_epilog}; rc ocspd restart" \
        $ocspd_logfile

