#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
##
##  rc.amd -- Run-Commands for AMD
##

%config
    amd_enable="yes"
    amd_log_prolog="true"
    amd_log_epilog="true"
    amd_log_numfiles="10"
    amd_log_minsize="1M"
    amd_log_complevel="9"

%start -p 200 -u @l_susr@
    opServiceEnabled amd || exit 0
    @l_prefix@/sbin/amd -F @l_prefix@/etc/amd/amd.conf >/dev/null 2>&1

%stop -p 200 -u @l_susr@
    opServiceEnabled amd || exit 0
    if [ -f @l_prefix@/var/amd/amd.pid ]; then
        kill -TERM `cat @l_prefix@/var/amd/amd.pid`
    fi

%restart -u @l_susr@
    opServiceEnabled amd || exit 0
    if [ -f @l_prefix@/var/amd/amd.pid ]; then
        kill -TERM `cat @l_prefix@/var/amd/amd.pid`
        sleep 2
    fi
    @l_prefix@/sbin/amd -F @l_prefix@/etc/amd/amd.conf >/dev/null 2>&1

%reload -u @l_susr@
    opServiceEnabled amd || exit 0
    if [ -f @l_prefix@/var/amd/amd.pid ]; then
        kill -HUP `cat @l_prefix@/var/amd/amd.pid`
    fi

%daily -u @l_susr@
    opServiceEnabled amd || exit 0
    shtool rotate -f \
        -n ${amd_log_numfiles} -s ${amd_log_minsize} -d \
        -z ${amd_log_complevel} -o @l_musr@ -g @l_mgrp@ -m 644 \
        -P "$amd_log_prolog" \
        -E "$amd_log_epilog" \
        @l_prefix@/var/amd/amd.log

