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

%config
    davical_enable="$openpkg_rc_def"

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

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

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

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

