limit logs size with logrotate

This commit is contained in:
nachoparker 2018-10-07 14:10:44 -06:00
parent 694a885597
commit 48ac238f5b
3 changed files with 32 additions and 1 deletions

View File

@ -21,6 +21,9 @@ install()
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ufw
systemctl disable ufw
# Disable logging to kernel
grep -q maxsize /etc/logrotate.d/ufw || sed -i /weekly/amaxsize2M /etc/logrotate.d/ufw
}
configure()

13
ncp.sh
View File

@ -184,6 +184,19 @@ EOF
# update to latest version from github as part of the build process
bin/ncp-update $BRANCH
# LIMIT LOG SIZE
grep -q maxsize /etc/logrotate.d/apache2 || sed -i /weekly/amaxsize2M /etc/logrotate.d/apache2
cat >> /etc/logrotate.d/ncp <<'EOF'
/var/log/ncp.log
{
rotate 4
size 500K
missingok
notifempty
compress
}
EOF
# ONLY FOR IMAGE BUILDS
if [[ -f /.ncp-image ]]; then
rm -rf /var/log/ncp.log

View File

@ -216,7 +216,6 @@ Package: *
Pin: release n=stretch
Pin-Priority: 600
EOF
apt-get update
apt-get purge -y php7.0-*
@ -288,6 +287,22 @@ EOF
URL="$(ncc config:system:get overwrite.cli.url)"
[[ "${URL: -1}" != "/" ]] && ncc config:system:set overwrite.cli.url --value="${URL}/"
# Implement logrotate restrictions
grep -q "^\& stop" /etc/rsyslog.d/20-ufw.conf || echo "& stop" >> /etc/rsyslog.d/20-ufw.conf
grep -q maxsize /etc/logrotate.d/ufw || sed -i /weekly/amaxsize2M /etc/logrotate.d/ufw
grep -q maxsize /etc/logrotate.d/apache2 || sed -i /weekly/amaxsize2M /etc/logrotate.d/apache2
service rsyslog restart
cat >> /etc/logrotate.d/ncp <<'EOF'
/var/log/ncp.log
{
rotate 4
size 500K
missingok
notifempty
compress
}
EOF
} # end - only live updates
exit 0