diff options
author | nachoparker <nacho@ownyourbits.com> | 2018-10-07 23:10:44 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2018-10-07 23:10:44 +0300 |
commit | 48ac238f5bb71249afc5564e2bc6aab955663b9d (patch) | |
tree | 80dfa9da091cf3594aae5926c9d5a0e7f55c6d2a | |
parent | 694a885597727c93672c099d6056d710a0435b19 (diff) |
limit logs size with logrotatev0.62.10
-rw-r--r-- | etc/ncp-config.d/UFW.sh | 3 | ||||
-rw-r--r-- | ncp.sh | 13 | ||||
-rwxr-xr-x | update.sh | 17 |
3 files changed, 32 insertions, 1 deletions
diff --git a/etc/ncp-config.d/UFW.sh b/etc/ncp-config.d/UFW.sh index b12380d3..3676e338 100644 --- a/etc/ncp-config.d/UFW.sh +++ b/etc/ncp-config.d/UFW.sh @@ -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() @@ -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 @@ -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 |