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

%config
    typo3_enable="$openpkg_rc_def"
    typo3_cron="yes"

%common
    typo3_apache_cfgfile="@l_prefix@/etc/typo3/typo3-apache.conf"
    typo3_apache_pidfile="@l_prefix@/var/typo3/run/typo3-apache.pid"

%status -u @l_susr@ -o
    typo3_usable="no"
    typo3_active="no"
    @l_prefix@/sbin/apache -t -f $typo3_apache_cfgfile 2>/dev/null && \
        typo3_usable="yes"
    [ -f $typo3_apache_pidfile ] && \
        kill -0 `cat $typo3_apache_pidfile` && \
        typo3_active="yes"
    echo "typo3_enable=\"$typo3_enable\""
    echo "typo3_usable=\"$typo3_usable\""
    echo "typo3_active=\"$typo3_active\""

%start -u @l_susr@
    rcService typo3 enable yes || exit 0
    rcService typo3 active yes && exit 0
    @l_prefix@/sbin/apache -f $typo3_apache_cfgfile

%stop -u @l_susr@
    rcService typo3 enable yes || exit 0
    rcService typo3 active no  && exit 0
    [ -f $typo3_apache_pidfile ] && \
        kill -TERM `cat $typo3_apache_pidfile`
    sleep 2

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

