diff --git a/BashScripts/install-apache.sh b/BashScripts/install-apache.sh index c672e04..f90654b 100644 --- a/BashScripts/install-apache.sh +++ b/BashScripts/install-apache.sh @@ -165,4 +165,37 @@ a2enmod proxy_http 2>>install.log && systemctl restart apache2 2>>install.log && +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 diff --git a/BashScripts/install-apache/apache-install-logrotate.sh b/BashScripts/install-apache/apache-install-logrotate.sh new file mode 100644 index 0000000..b0437db --- /dev/null +++ b/BashScripts/install-apache/apache-install-logrotate.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# Make sure script is ran as root +if [[ $EUID -ne 0 ]]; then + exec sudo /bin/bash "$0" "$@" +fi +