Add logrotate configuration.

This commit is contained in:
Christoph 2017-10-18 12:36:21 +02:00
parent 968cba3ef9
commit 9dbc786c44
2 changed files with 80 additions and 1 deletions

View File

@ -57,6 +57,9 @@ echo_ok() {
echo_failed(){
echo -e " [ \033[1;31mfailed\033[m ]"
}
echo_skipped(){
echo -e " [ \033[1;33mskipped\033[m ]"
}
## --------------------------------------------------
@ -563,6 +566,43 @@ elif [ -f /etc/man.conf];then
fi
echo ""
echo -n -e "\tConfigure logrotation.."
if [ ! -f "/etc/logrotate.d/apache2" ]; then
cat <<EOF > /etc/logrotate.d/apache2
/var/log/apache2/*log
/var/log/apache2/*error
/var/www/*/logs/*log
/var/www/*/logs/*error {
daily
missingok
rotate 7
compress
delaycompress
notifempty
create 644 root adm
sharedscripts
postrotate
chown ${HTTPD_USER}:${HTTPD_GROUP} /var/www/*/logs/php_errors.log
chown ${HTTPD_USER}:${HTTPD_GROUP} /var/log/apache2/php_errors.log
APACHECTL="\$(which apachectl)"
if [[ -z "\$APACHECTL" ]] ; then
echo "Prog 'apachectl' not found!"
else
\$APACHECTL graceful > /dev/null
fi
endscript
}
EOF
if [ "$?" = "0" ]; then
echo_ok
else
echo_failed
fi
else
echo_skipped
fi
## - Add /usr/local/apache2/bin to the systems PATH variable
## -

View File

@ -1609,7 +1609,7 @@ echo -e "\t---"
echo ""
if [ -f $_httpdconf ];then
cp $_httpdconf $_httpdconf.ORIG
cp -a $_httpdconf $_httpdconf.ORIG
if $subst_base_path ; then
## - set BasePath to httpd.conf
@ -3561,6 +3561,45 @@ else
warn "Creating ${GLOBAL_DOC_ROOT}/index.html (Error 404 page) failed."
fi
echo "" >> ${_logdir}/main.log
echo "## -" >> ${_logdir}/main.log
echo "## - Configure logrotation.." >> ${_logdir}/main.log
echononl "\tConfigure logrotation...."
if [ ! -f "/etc/logrotate.d/apache2" ]; then
cat <<EOF > /etc/logrotate.d/apache2
/var/log/apache2/*log
/var/log/apache2/*error
/var/www/*/logs/*log
/var/www/*/logs/*error {
daily
missingok
rotate 7
compress
delaycompress
notifempty
create 644 root adm
sharedscripts
postrotate
chown ${HTTPD_USER}:${HTTPD_GROUP} /var/www/*/logs/php_errors.log
chown ${HTTPD_USER}:${HTTPD_GROUP} /var/log/apache2/php_errors.log
APACHECTL="\$(which apachectl)"
if [[ -z "\$APACHECTL" ]] ; then
echo "Prog 'apachectl' not found!"
else
\$APACHECTL graceful > /dev/null
fi
endscript
}
EOF
if [ "$?" = "0" ]; then
echo_ok
else
echo_failed
fi
else
echo_skipped
fi
if $START_APACHE_WEBSERVICE ; then
echo "" >> ${_logdir}/main.log
echo "" >> ${_logdir}/main.log