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

%config
    crossroads_enable="$openpkg_rc_def"
    crossroads_log_prolog="true"
    crossroads_log_epilog="true"
    crossroads_log_numfiles="10"
    crossroads_log_minsize="1M"
    crossroads_log_complevel="9"

%common
    crossroads_logfile="@l_prefix@/var/crossroads/crossroads.log"

%status -u @l_susr@ -o
    crossroads_usable="no"
    crossroads_active="no"
    @l_prefix@/bin/crossroads configtest >/dev/null 2>&1 && \
        crossroads_usable="yes"
    rcService crossroads enable yes && \
        @l_prefix@/bin/crossroads status >/dev/null 2>&1 && \
        crossroads_active="yes"
    echo "crossroads_enable=\"$crossroads_enable\""
    echo "crossroads_usable=\"$crossroads_usable\""
    echo "crossroads_active=\"$crossroads_active\""

%start -u @l_susr@
    rcService crossroads enable yes || exit 0
    rcService crossroads active yes && exit 0
    @l_prefix@/bin/crossroads start

%stop -u @l_susr@
    rcService crossroads enable yes || exit 0
    rcService crossroads active no  && exit 0
    @l_prefix@/bin/crossroads stop

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

%daily -u @l_susr@
    rcService crossroads enable yes || exit 0
    shtool rotate -f \
        -n ${crossroads_log_numfiles} -s ${crossroads_log_minsize} -d \
        -z ${crossroads_log_complevel} -m 664 -o @l_nusr@ -g @l_ngrp@ \
        -P "${crossroads_log_prolog}" \
        -E "${crossroads_log_epilog}; rc crossroads restart" \
        $crossroads_logfile

