Skip to content

Commit

Permalink
limit logs size with logrotate
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Oct 7, 2018
1 parent 694a885 commit 48ac238
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
3 changes: 3 additions & 0 deletions etc/ncp-config.d/UFW.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
13 changes: 13 additions & 0 deletions ncp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ Package: *
Pin: release n=stretch
Pin-Priority: 600
EOF

apt-get update

apt-get purge -y php7.0-*
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 48ac238

Please sign in to comment.