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

%config
    arpd_enable="$openpkg_rc_def"
    arpd_log_prolog="true"
    arpd_log_epilog="true"
    arpd_log_numfiles="10"
    arpd_log_minsize="1M"
    arpd_log_complevel="9"
    arpd_ip_network="192.168.100.0/24"
    arpd_if=""

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

%status -u @l_susr@ -o
    arpd_usable="unknown"
    arpd_active="no"
    rcService arpd enable yes && \
        arpd_signal 0 && arpd_active="yes"
    echo "arpd_enable=\"$arpd_enable\""
    echo "arpd_usable=\"$arpd_usable\""
    echo "arpd_active=\"$arpd_active\""

%start -u @l_susr@
    rcService arpd enable yes || exit 0
    rcService arpd active yes && exit 0
    if [ ".$arpd_if" != . ]; then
        arpd_interface="-i $arpd_if"
    fi
    @l_prefix@/sbin/arpd \
        $arpd_interface \
        $arpd_ip_network \
        >/dev/null 2>&1

%stop -u @l_susr@
    rcService arpd enable yes || exit 0
    rcService arpd active no && exit 0
    arpd_signal TERM

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

%reload -u @l_susr@
    rcService arpd enable yes || exit 0
    rcService arpd active no && exit 0
    arpd_signal HUP

%daily -u @l_susr@
    rcService arpd enable yes || exit 0
    shtool rotate -f \
        -n ${arpd_log_numfiles} -s ${arpd_log_minsize} -d \
        -z ${arpd_log_complevel} -o @l_susr@ -g @l_rgrp@ -m 644 \
        -P "${arpd_log_prolog}" \
        -E "${arpd_log_epilog}; rc arpd restart" \
        @l_prefix@/var/arpd/arpd.log

