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

%config
    prngd_enable="$openpkg_rc_def"
    prngd_socket="@l_prefix@/var/prngd/prngd.socket"
    prngd_log_prolog="true"
    prngd_log_epilog="true"
    prngd_log_numfiles="10"
    prngd_log_minsize="1M"
    prngd_log_complevel="9"

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

%status -u @l_susr@ -o
    prngd_usable="unknown"
    prngd_active="no"
    rcService prngd enable yes && \
        prngd_signal 0 && prngd_active="yes"
    echo "prngd_enable=\"$prngd_enable\""
    echo "prngd_usable=\"$prngd_usable\""
    echo "prngd_active=\"$prngd_active\""

%start -p 100 -u @l_susr@
    rcService prngd enable yes || exit 0
    rcService prngd active yes && exit 0
    @l_prefix@/sbin/prngd -p $prngd_pidfile -m 660 $prngd_socket

%stop -p 900 -u @l_susr@
    rcService prngd enable yes || exit 0
    rcService prngd active no  && exit 0
    @l_prefix@/sbin/prngd -k -p $prngd_pidfile -m 660 $prngd_socket
    rm -f $prngd_socket 2>/dev/null || true

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

%daily -u @l_susr@
    rcService prngd enable yes || exit 0
    shtool rotate -f \
        -n ${prngd_log_numfiles} -s ${prngd_log_minsize} -d \
        -z ${prngd_log_complevel} -m 644 -o @l_susr@ -g @l_mgrp@ \
        -P "${prngd_log_prolog}" \
        -E "${prngd_log_epilog}; rc prngd restart" \
        @l_prefix@/var/prngd/prngd.log

