Add apache-install-logrotate.sh
This commit is contained in:
parent
0e0531154e
commit
6cf3e999ab
@ -165,4 +165,37 @@ a2enmod proxy_http 2>>install.log &&
|
|||||||
|
|
||||||
systemctl restart apache2 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 <<EOT >> "/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'
|
echo 'Installation complete'
|
6
BashScripts/install-apache/apache-install-logrotate.sh
Normal file
6
BashScripts/install-apache/apache-install-logrotate.sh
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Make sure script is ran as root
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
exec sudo /bin/bash "$0" "$@"
|
||||||
|
fi
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user