From cc65eaeb954fe81a82dc4de2337a70b52df0e1ee Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 7 Sep 2018 07:28:46 +0200 Subject: [PATCH] saving uncommitted changes in /etc prior to apt run --- .etckeeper | 2 ++ cron.daily/logrotate | 16 +++++++++++- logrotate.conf | 26 +++---------------- logrotate.d/btmp | 5 +++- logrotate.d/wtmp | 6 +++-- .../logrotate.service.d/exec-script.conf | 4 +++ 6 files changed, 33 insertions(+), 26 deletions(-) create mode 100644 systemd/system/logrotate.service.d/exec-script.conf diff --git a/.etckeeper b/.etckeeper index 438cd1d..c5c97b1 100755 --- a/.etckeeper +++ b/.etckeeper @@ -653,6 +653,8 @@ maybe chmod 0755 'systemd/system/default.target.wants' maybe chmod 0755 'systemd/system/getty.target.wants' maybe chmod 0755 'systemd/system/getty@.service.d' maybe chmod 0644 'systemd/system/getty@.service.d/noclear.conf' +maybe chmod 0755 'systemd/system/logrotate.service.d' +maybe chmod 0644 'systemd/system/logrotate.service.d/exec-script.conf' maybe chmod 0755 'systemd/system/multi-user.target.wants' maybe chmod 0755 'systemd/system/network-online.target.wants' maybe chmod 0755 'systemd/system/sockets.target.wants' diff --git a/cron.daily/logrotate b/cron.daily/logrotate index 189da6a..ae30c1d 100755 --- a/cron.daily/logrotate +++ b/cron.daily/logrotate @@ -1,9 +1,23 @@ #!/bin/bash -test -x /usr/sbin/logrotate || exit 0 +# skip in favour of systemd timer +if [[ -d /run/systemd/system ]]; then + exit 0 +fi + +# this cronjob persists removals (but not purges) +if [[ ! -x /usr/sbin/logrotate ]]; then + exit 0 +fi + LOG=/var/log/logrotate.log echo >> ${LOG} echo "################################################" >> ${LOG} echo "[$(date --rfc-3339=seconds )]: Start Logrotating" >> ${LOG} /usr/sbin/logrotate /etc/logrotate.conf >> ${LOG} 2>&1 +EXITVALUE=$? +if [ $EXITVALUE != 0 ]; then + /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]" +fi echo "[$(date --rfc-3339=seconds )]: End Logrotating" >> ${LOG} +exit $EXITVALUE diff --git a/logrotate.conf b/logrotate.conf index 4eb8285..9dad9ec 100644 --- a/logrotate.conf +++ b/logrotate.conf @@ -8,6 +8,9 @@ rotate 99 # create new (empty) log files after rotating old ones create +# use date as a suffix of the rotated file +dateext + # uncomment this if you want your log files compressed compress delaycompress @@ -15,25 +18,4 @@ delaycompress # packages drop log rotation information into this directory include /etc/logrotate.d -# no packages own wtmp, or btmp -- we'll rotate them here -/var/log/wtmp { - missingok - monthly - create 0664 root utmp - rotate 12 - dateext - dateformat -%Y-%m-%d - size 4M -} - -/var/log/btmp { - missingok - monthly - create 0660 root utmp - rotate 12 - dateext - dateformat -%Y-%m-%d - size 4M -} - -# system-specific logs may be configured here +# system-specific logs may be also be configured here. diff --git a/logrotate.d/btmp b/logrotate.d/btmp index 0aa1ae1..b6f82b4 100644 --- a/logrotate.d/btmp +++ b/logrotate.d/btmp @@ -3,5 +3,8 @@ missingok monthly create 0660 root utmp - rotate 1 + minsize 4M + rotate 12 + dateext + dateformat -%Y-%m-%d } diff --git a/logrotate.d/wtmp b/logrotate.d/wtmp index cc8a151..fa9ca38 100644 --- a/logrotate.d/wtmp +++ b/logrotate.d/wtmp @@ -3,6 +3,8 @@ missingok monthly create 0664 root utmp - minsize 1M - rotate 1 + minsize 4M + rotate 12 + dateext + dateformat -%Y-%m-%d } diff --git a/systemd/system/logrotate.service.d/exec-script.conf b/systemd/system/logrotate.service.d/exec-script.conf new file mode 100644 index 0000000..effc0ab --- /dev/null +++ b/systemd/system/logrotate.service.d/exec-script.conf @@ -0,0 +1,4 @@ +[Service] +ExecStart=/root/bin/logrotate + +# vim: filetype=dosini -- 2.39.5