From f495e0d793e14e0409fd52f0227642443dbe7209 Mon Sep 17 00:00:00 2001 From: Johan Date: Wed, 8 Mar 2023 12:03:08 +0100 Subject: [PATCH] Update apache-install-logrotate.sh --- .../apache-install-logrotate.sh | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/BashScripts/install-apache/apache-install-logrotate.sh b/BashScripts/install-apache/apache-install-logrotate.sh index b0437db..73ddb7c 100644 --- a/BashScripts/install-apache/apache-install-logrotate.sh +++ b/BashScripts/install-apache/apache-install-logrotate.sh @@ -4,3 +4,37 @@ if [[ $EUID -ne 0 ]]; then exec sudo /bin/bash "$0" "$@" fi +logrotate --version 2>&1 || ( + echo "Installing Logrotate..." + apt install logrotate -y 2>>install.log && + logrotate --version +) +if ! grep -q "/var/www/\*/logs/\*\.log" "/etc/logrotate.d/apache2"; then + echo "Adding logrotate config" + cat <> "/etc/logrotate.d/apache2" +/var/www/*/logs/*.log { + su root root + maxsize 50M + daily + missingok + rotate 7 + compress + delaycompress + notifempty + create 640 root adm + sharedscripts + postrotate + if invoke-rc.d apache2 status > /dev/null 2>&1; then \ + invoke-rc.d apache2 reload > /dev/null 2>&1; \ + fi; + endscript + prerotate + if [ -d /etc/logrotate.d/httpd-prerotate ]; then \ + run-parts /etc/logrotate.d/httpd-prerotate; \ + fi; \ + endscript +} +EOT +fi + +echo 'Installation complete' \ No newline at end of file