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

%config
    honeyd_enable="$openpkg_rc_def"
    honeyd_log_prolog="true"
    honeyd_log_epilog="true"
    honeyd_log_numfiles="10"
    honeyd_log_minsize="1M"
    honeyd_log_complevel="9"
    honeyd_ip_network="192.168.100.0/24"
    honeyd_if=""

%common
    honeyd_pidfile="@l_prefix@/var/honeyd/honeyd.pid"
    honeyd_cfgfile="@l_prefix@/etc/honeyd/honeyd.conf"
    honeyd_prnfile="@l_prefix@/share/honeyd/nmap.prints"
    honeyd_xpbfile="@l_prefix@/share/honeyd/xprobe2.conf"
    honeyd_assfile="@l_prefix@/share/honeyd/nmap.assoc"
    honeyd_signal () {
        [ -f $honeyd_pidfile ] && kill -$1 `cat $honeyd_pidfile`
    }

%status -u @l_susr@ -o
    honeyd_usable="no"
    honeyd_active="no"
    rcService honeyd enable yes && \
        honeyd_chroot && honeyd_usable="yes"
    rcService honeyd enable yes && \
        honeyd_signal 0 && honeyd_active="yes"
    echo "honeyd_enable=\"$honeyd_enable\""
    echo "honeyd_usable=\"$honeyd_usable\""
    echo "honeyd_active=\"$honeyd_active\""

%start -u @l_susr@
    rcService honeyd enable yes || exit 0
    rcService honeyd active yes && exit 0
    if [ ".$honeyd_if" != . ]; then
        arpd_interface="-i $honeyd_if"
    fi
    @l_prefix@/bin/honeyd \
        -p $honeyd_prnfile \
        -x $honeyd_xpbfile \
        -a $honeyd_assfile \
        -f $honeyd_cfgfile \
        $honeyd_interface \
        $honeyd_ip_network \
        >/dev/null 2>&1

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

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

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

%daily -u @l_susr@
    rcService honeyd enable yes || exit 0
    shtool rotate -f \
        -n ${honeyd_log_numfiles} -s ${honeyd_log_minsize} -d \
        -z ${honeyd_log_complevel} -o @l_susr@ -g @l_mgrp@ -m 644 \
        -P "${honeyd_log_prolog}" \
        -E "${honeyd_log_epilog}; rc honeyd restart" \
        @l_prefix@/var/honeyd/honeyd.log

