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

%config
    htdig_enable="$openpkg_rc_def"
    htdig_update="daily"
    htdig_flags="-v"
    htdig_log_prolog="true"
    htdig_log_epilog="true"
    htdig_log_numfiles="10"
    htdig_log_minsize="1M"
    htdig_log_complevel="9"

%common
    htdig_logfile="@l_prefix@/var/htdig/run/htdig.log"
    htdig_update () {
        @l_prefix@/bin/rundig $htdig_flags >>$htdig_logfile
    }

%hourly -u @l_rusr@
    rcService htdig enable yes || exit 0
    if [ ".$htdig_update" = .hourly ]; then
        htdig_update || exit $?
    fi

%daily -u @l_rusr@
    rcService htdig enable yes || exit 0
    if [ ".$htdig_update" = .daily ]; then
        htdig_update || exit $?
    fi
    shtool rotate -f \
        -n ${htdig_log_numfiles} -s ${htdig_log_minsize} -d \
        -z ${htdig_log_complevel} -m 644 -o @l_rusr@ -g @l_rgrp@ \
        -P "${htdig_log_prolog}" \
        -E "${htdig_log_epilog}" \
        $htdig_logfile

%weekly -u @l_rusr@
    rcService htdig enable yes || exit 0
    if [ ".$htdig_update" = .weekly ]; then
        htdig_update || exit $?
    fi

