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

%config
    heartbeat_enable="$openpkg_rc_def"
    heartbeat_flags=""
    heartbeat_log_prolog="true"
    heartbeat_log_epilog="true"
    heartbeat_log_numfiles="10"
    heartbeat_log_minsize="1M"
    heartbeat_log_complevel="9"

%status -u @l_susr@ -o
    heartbeat_usable="no"
    heartbeat_active="no"
    @l_prefix@/sbin/heartbeat -s >/dev/null 2>&1 && heartbeat_active="yes"
    echo "heartbeat_enable=\"$heartbeat_enable\""
    echo "heartbeat_usable=\"$heartbeat_usable\""
    echo "heartbeat_active=\"$heartbeat_active\""

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

%stop -p 900 -u @l_susr@
    rcService heartbeat enable yes || exit 0
    rcService heartbeat active no  && exit 0
    @l_prefix@/sbin/heartbeat -k

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

%reload -u @l_susr@
    rcService heartbeat enable yes || exit 0
    rcService heartbeat active no  && exit 0
    @l_prefix@/sbin/heartbeat -r

%daily -u @l_susr@
    rcService heartbeat enable yes || exit 0
    shtool rotate -f \
        -n ${heartbeat_log_numfiles} -s ${heartbeat_log_minsize} -d \
        -z ${heartbeat_log_complevel} -m 644 -o @l_rusr@ -g @l_rgrp@ \
        -P "${heartbeat_log_prolog}" \
        -E "${heartbeat_log_epilog} && rc heartbeat reload" \
        @l_prefix@/var/heartbeat/ha.log

