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

%config
    cacti_enable="$openpkg_rc_def"

%status -u @l_susr@ -o
    cacti_usable="no"
    cacti_active="no"
    @l_prefix@/sbin/apache -t \
        -f @l_prefix@/etc/cacti/cacti-apache.conf 2>/dev/null && \
        cacti_usable="yes"
    [ -f @l_prefix@/var/cacti/run/apache.pid ] && \
        kill -0 `cat @l_prefix@/var/cacti/run/apache.pid` && \
        cacti_active="yes"
    echo "cacti_enable=\"$cacti_enable\""
    echo "cacti_usable=\"$cacti_usable\""
    echo "cacti_active=\"$cacti_active\""

%start -u @l_susr@
    rcService cacti enable yes || exit 0
    rcService cacti active yes && exit 0
    @l_prefix@/sbin/apache \
        -f @l_prefix@/etc/cacti/cacti-apache.conf

%stop -u @l_susr@
    rcService cacti enable yes || exit 0
    rcService cacti active no  && exit 0
    [ -f @l_prefix@/var/cacti/run/apache.pid ] && \
        kill -TERM `cat @l_prefix@/var/cacti/run/apache.pid`
    sleep 2

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

