#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
##
##  rc.apache -- Apache Administration Run-Commands
##

%config
    apache_enable="yes"
    apache_log_files="@l_prefix@/var/apache/log/access.log"
    apache_log_rotsteps="10"
    apache_log_rotminsize="10M"
    apache_log_rotcomplevel="9"
    apache_log_rotprolog="true"
    apache_log_rotepilog="true"
    apache_err_files="@l_prefix@/var/apache/log/error.log"
    apache_err_rotsteps="10"
    apache_err_rotminsize="1M"
    apache_err_rotcomplevel="9"
    apache_err_rotprolog="true"
    apache_err_rotepilog="true"

%start -p 200 -u root
    opServiceEnabled apache || exit 0
    @l_prefix@/sbin/apachectl start

%stop -p 200 -u root
    opServiceEnabled apache || exit 0
    @l_prefix@/sbin/apachectl stop
    sleep 2

%restart -u root
    opServiceEnabled apache || exit 0
    @l_prefix@/sbin/apachectl restart

%daily -u root
    opServiceEnabled apache || exit 0
    if [ ".$apache_log_files" != . ]; then
        shtool rotate -f \
            -n${apache_log_rotsteps} -s${apache_log_rotminsize} -d \
            -z${apache_log_rotcomplevel} -o@l_musr@ -g@l_mgrp@ -m644 \
            -P "$apache_log_rotprolog" \
            -E "@l_prefix@/sbin/apachectl restart; $apache_log_rotepilog" \
            $apache_log_files
    fi
    if [ ".$apache_err_files" != . ]; then
        shtool rotate -f \
            -n${apache_err_rotsteps} -s${apache_err_rotminsize} -d \
            -z${apache_err_rotcomplevel} -o@l_musr@ -g@l_mgrp@ -m644 \
            -P "$apache_err_rotprolog" \
            -E "@l_prefix@/sbin/apachectl restart; $apache_err_rotepilog" \
            $apache_err_files
    fi

