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

%config
    oidentd_enable="$openpkg_rc_def"
    oidentd_listen="127.0.0.1"
    oidentd_maxclients="32"
    oidentd_timeout="20"
    oidentd_flags=""
    oidentd_log_prolog="true"
    oidentd_log_epilog="true"
    oidentd_log_numfiles="10"
    oidentd_log_minsize="1M"
    oidentd_log_complevel="9"

%common
    oidentd_pidfile="@l_prefix@/var/oidentd/oidentd.pid"
    oidentd_logfile="@l_prefix@/var/oidentd/oidentd.log"
    oidentd_signal () {
        [ -f $oidentd_pidfile ] && kill -$1 `cat $oidentd_pidfile`
    }

%status -u @l_susr@ -o
    oidentd_usable="unknown"
    oidentd_active="no"
    rcService oidentd enable yes && \
        oidentd_signal 0 && oidentd_active="yes"
    echo "oidentd_enable=\"$oidentd_enable\""
    echo "oidentd_usable=\"$oidentd_usable\""
    echo "oidentd_active=\"$oidentd_active\""

%start -p 100 -u @l_susr@
    rcService oidentd enable yes || exit 0
    rcService oidentd active yes && exit 0
    @l_prefix@/sbin/oidentd \
        --address=${oidentd_listen} \
        --limit=${oidentd_maxclient} \
        --timeout=${oidentd_timeout} \
        --other="Unix/OpenPKG" \
        --nosyslog \
        ${oidentd_flags} \
        >/dev/null 2>>${oidentd_logfile}

%stop -p 900 -u @l_susr@
    rcService oidentd enable yes || exit 0
    rcService oidentd active no  && exit 0
    oidentd_signal TERM
    sleep 2
    rm -f $oidentd_pidfile >/dev/null 2>&1 || true

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

%daily -u @l_susr@
    rcService oidentd enable yes || exit 0
    shtool rotate -f \
        -n ${oidentd_log_numfiles} -s ${oidentd_log_minsize} -d \
        -z ${oidentd_log_complevel} -m 644 -o @l_susr@ -g @l_mgrp@ \
        -P "${oidentd_log_prolog}" \
        -E "${oidentd_log_epilog}; rc oidentd restart" \
        ${oidentd_logfile}

