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

%config
    limesurvey_enable="$openpkg_rc_def"
    limesurvey_backup="daily"

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

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

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

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

