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

%config
    actordb_enable="$openpkg_rc_def"
    actordb_flags=""
    actordb_log_prolog="true"
    actordb_log_epilog="true"
    actordb_log_numfiles="10"
    actordb_log_minsize="1M"
    actordb_log_complevel="9"

%common
    actordb_pidfile="@l_prefix@/var/actordb/run/actordb.pid"
    actordb_logfile="@l_prefix@/var/actordb/log/actordb.log"
    actordb_server () {
        cd @l_prefix@/libexec/actordb
        @l_prefix@/bin/actordb ${1+"$@"}
    }

%status -u @l_rusr@ -o
    actordb_usable="no"
    actordb_active="no"
    actordb_server chkconfig >/dev/null 2>&1
    if [ $? -eq 0 ]; then
        actordb_usable="yes"
    fi
    rcService actordb enable yes
    if [ $? -eq 0 ]; then
        actordb_server ping >/dev/null 2>&1
        if [ $? -eq 0 ]; then
            actordb_active="yes"
        fi
    fi
    echo "actordb_enable=\"$actordb_enable\""
    echo "actordb_usable=\"$actordb_usable\""
    echo "actordb_active=\"$actordb_active\""

%start -u @l_rusr@
    rcService actordb enable yes || exit 0
    rcService actordb active yes && exit 0
    actordb_server start $actordb_flags \
        </dev/null >>$actordb_logfile 2>&1

%stop -u @l_rusr@
    rcService actordb enable yes || exit 0
    rcService actordb active no  && exit 0
    actordb_server stop

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

%daily -u @l_rusr@
    rcService actordb enable yes || exit 0
    shtool rotate -f \
        -n ${actordb_log_numfiles} -s ${actordb_log_minsize} -d \
        -z ${actordb_log_complevel} -m 664 -o @l_rusr@ -g @l_rgrp@ \
        -P "${actordb_log_prolog}" \
        -E "${actordb_log_epilog}; rc actordb restart" \
        $actordb_logfile

