summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authordougb <dougb@FreeBSD.org>2011-11-13 03:01:58 +0000
committerdougb <dougb@FreeBSD.org>2011-11-13 03:01:58 +0000
commit9d00c3ae5660b9ceb7d40f15a8fa88fe3414dc30 (patch)
tree69a6cf4d52fd346ebadca1fb48e60a606bd6293b /etc
parent2c9fd688ffe7082186ee2e70a137bda8fc4413c0 (diff)
downloadFreeBSD-src-9d00c3ae5660b9ceb7d40f15a8fa88fe3414dc30.zip
FreeBSD-src-9d00c3ae5660b9ceb7d40f15a8fa88fe3414dc30.tar.gz
The default setting, daily_accounting_compress="NO", was causing
only 1 old file to be saved, so fix this. Problem raised in the PR, but actually required a different solution. While I'm here, fix a very old off-by-one error causing 1 more file than specified in daily_accounting_save to be saved because acct.0 was not taken into account (pun intended). Change that, and use a more thorough method of finding old files to delete. Partly just because this is the right thing to do, but also to silently fix the extra log that would have been left behind forever with the previous method. PR: conf/160848 Submitted by: Andrey Zonov <andrey@zonov.org>
Diffstat (limited to 'etc')
-rwxr-xr-xetc/periodic/daily/310.accounting18
1 files changed, 12 insertions, 6 deletions
diff --git a/etc/periodic/daily/310.accounting b/etc/periodic/daily/310.accounting
index b964616..d11745d 100755
--- a/etc/periodic/daily/310.accounting
+++ b/etc/periodic/daily/310.accounting
@@ -30,8 +30,13 @@ case "$daily_accounting_enable" in
cd /var/account
rc=0
- n=$daily_accounting_save
- rm -f acct.$n.gz acct.$n || rc=3
+ n=$(( $daily_accounting_save - 1 ))
+ for f in acct.*; do
+ case "$f" in acct.\*) continue ;; esac # No files match
+ m=${f%.gz} ; m=${m#acct.}
+ [ $m -ge $n ] && { rm $f || rc=3; }
+ done
+
m=$n
n=$(($n - 1))
while [ $n -ge 0 ]
@@ -44,13 +49,14 @@ case "$daily_accounting_enable" in
/etc/rc.d/accounting rotate_log || rc=3
+ rm -f acct.merge && cp acct.0 acct.merge || rc=3
+ sa -s $daily_accounting_flags /var/account/acct.merge || rc=3
+ rm acct.merge
+
case "$daily_accounting_compress" in
[Yy][Ee][Ss])
- gzip --keep -f acct.0 || rc=3;;
+ gzip -f acct.0 || rc=3;;
esac
-
- sa -s $daily_accounting_flags /var/account/acct.0 &&
- unlink acct.0 || rc=3
fi;;
*) rc=0;;
OpenPOWER on IntegriCloud