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

%config
    uucp_enable="$openpkg_rc_def"
    uucp_flags="-l"
    uucp_bind="127.0.0.1"
    uucp_port="540"
    uucp_log_prolog="true"
    uucp_log_epilog="true"
    uucp_log_numfiles="10"
    uucp_log_minsize="1M"
    uucp_log_complevel="9"

%common
    uucp_pidfile="@l_prefix@/var/uucp/run/uucpd.pid"
    uucp_signal () {
        [ -f $uucp_pidfile ] && kill -$1 `cat $uucp_pidfile`
    }
    uucp_start () {
        ( @l_prefix@/sbin/uucpd ${uucp_bind}${uucp_bind:+:}${uucp_port:-uucp} \
          @l_prefix@/sbin/uucico ${uucp_flags} \
          </dev/null >/dev/null 2>&1 &
          echo $! >$uucp_pidfile
        ) </dev/null >/dev/null 2>&1
    }

%status -u @l_susr@ -o
    uucp_usable="unknown"
    uucp_active="no"
    rcService uucp enable yes && \
        uucp_signal 0 && uucp_active="yes"
    echo "uucp_enable=\"$uucp_enable\""
    echo "uucp_usable=\"$uucp_usable\""
    echo "uucp_active=\"$uucp_active\""

%start -u @l_susr@
    rcService uucp enable yes || exit 0
    rcService uucp active yes && exit 0
    uucp_start

%stop -u @l_susr@
    rcService uucp enable yes || exit 0
    rcService uucp active no  && exit 0
    uucp_signal TERM
    sleep 2
    rm -f $uucp_pidfile 2>/dev/null || true

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

%daily -u @l_susr@
    rcService uucp enable yes || exit 0
    shtool rotate -f \
        -n ${uucp_log_numfiles} -s ${uucp_log_minsize} -d \
        -z ${uucp_log_complevel} -m 644 -o @l_musr@ -g @l_mgrp@ \
        -P "${uucp_log_prolog}" \
        -E "${uucp_log_epilog}; rc uucp restart" \
        @l_prefix@/var/uucp/log/uucp.debug \
        @l_prefix@/var/uucp/log/uucp.log \
        @l_prefix@/var/uucp/log/uucp.stat

