Update apache-install-logrotate.sh
This commit is contained in:
parent
6cf3e999ab
commit
f495e0d793
@ -4,3 +4,37 @@ if [[ $EUID -ne 0 ]]; then
|
|||||||
exec sudo /bin/bash "$0" "$@"
|
exec sudo /bin/bash "$0" "$@"
|
||||||
fi
|
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 <<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'
|
Loading…
x
Reference in New Issue
Block a user