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

%config
    gated_enable="$openpkg_rc_def"
    gated_log_prolog="true"
    gated_log_epilog="true"
    gated_log_numfiles="10"
    gated_log_minsize="1M"
    gated_log_complevel="9"

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

%status -u @l_susr@ -o
    gated_usable="unknown"
    gated_active="no"
    rcService gated enable yes && \
        gated_signal 0 && gated_active="yes"
    echo "gated_enable=\"$gated_enable\""
    echo "gated_usable=\"$gated_usable\""
    echo "gated_active=\"$gated_active\""

%start -u @l_susr@
    rcService gated enable yes || exit 0
    rcService gated active yes && exit 0
    @l_prefix@/sbin/gdc start

%stop -u @l_susr@
    rcService gated enable yes || exit 0
    rcService gated active no && exit 0
    @l_prefix@/sbin/gdc stop

%restart -u @l_susr@
    rcService gated enable yes || exit 0
    rcService gated active no && exit 0
    @l_prefix@/sbin/gdc restart

%daily -u @l_susr@
    rcService gated enable yes || exit 0
    shtool rotate -f \
        -n ${gated_log_numfiles} -s ${gated_log_minsize} -d \
        -z ${gated_log_complevel} -o @l_susr@ -g @l_mgrp@ -m 644 \
        -P "${gated_log_prolog}" \
        -E "${gated_log_epilog}" \
        @l_prefix@/var/gated/gated.log

