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

%config
    akka_enable="$openpkg_rc_def"
    akka_flags=""
    akka_log_prolog="true"
    akka_log_epilog="true"
    akka_log_numfiles="10"
    akka_log_minsize="1M"
    akka_log_complevel="9"

%common
    akka_pidfile="@l_prefix@/var/akka/log/akka.pid"
    akka_signal () {
        [ -f $akka_pidfile ] && kill -$1 `cat $akka_pidfile`
    }

%status -u @l_rusr@ -o
    akka_usable="unknown"
    akka_active="no"
    rcService akka enable yes && \
        akka_signal 0 && akka_active="yes"
    echo "akka_enable=\"$akka_enable\""
    echo "akka_usable=\"$akka_usable\""
    echo "akka_active=\"$akka_active\""

%start -u @l_rusr@
    rcService akka enable yes || exit 0
    rcService akka active yes && exit 0
    eval `JAVA_PLATFORM="sun-jdk" @l_prefix@/bin/java-toolkit -e`
    #   FIXME
    #   @l_prefix@/bin/akka ${akka_flags}

%stop -u @l_rusr@
    rcService akka enable yes || exit 0
    rcService akka active no && exit 0
    #   FIXME

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

%daily -u @l_rusr@
    rcService akka enable yes || exit 0
    shtool rotate -f \
        -n ${akka_log_numfiles} -s ${akka_log_minsize} -d \
        -z ${akka_log_complevel} -o @l_rusr@ -g @l_rgrp@ -m 644 \
        -P "${akka_log_prolog}" \
        -E "${akka_log_epilog}; rc akka restart" \
        @l_prefix@/var/akka/log/akka.log

