#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
##
##  rc.sysmon -- Run-Commands for SYSMON daemon
##

%config
    sysmon_enable="yes"

%common
    sysmon_pidfile="@l_prefix@/var/sysmon/sysmon.pid"

%start -p 200 -u root
    if opServiceEnabled sysmon; then
        opTmpDirGen sysmon
        opTmpDirFile sysmon log logfile
        @l_prefix@/sbin/sysmond -q -f @l_prefix@/etc/sysmon/sysmon.conf >$logfile 2>&1
        grep "pid" $logfile | sed -e 's;^.*pid \([0-9]*\).*$;\1;' >$sysmon_pidfile
        opTmpDirDel sysmon
    fi

%stop -p 200 -u root
    if opServiceEnabled sysmon; then
        if [ -f $sysmon_pidfile ]; then
            kill -TERM `cat $sysmon_pidfile`
        fi
    fi

