From owner-svn-src-all@FreeBSD.ORG Sun Nov 13 03:01:59 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 644C71065675; Sun, 13 Nov 2011 03:01:59 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3B4998FC12; Sun, 13 Nov 2011 03:01:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAD31xjZ073445; Sun, 13 Nov 2011 03:01:59 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAD31xYK073443; Sun, 13 Nov 2011 03:01:59 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201111130301.pAD31xYK073443@svn.freebsd.org> From: Doug Barton Date: Sun, 13 Nov 2011 03:01:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227482 - head/etc/periodic/daily X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Nov 2011 03:01:59 -0000 Author: dougb Date: Sun Nov 13 03:01:58 2011 New Revision: 227482 URL: http://svn.freebsd.org/changeset/base/227482 Log: 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 Modified: head/etc/periodic/daily/310.accounting Modified: head/etc/periodic/daily/310.accounting ============================================================================== --- head/etc/periodic/daily/310.accounting Sun Nov 13 02:32:10 2011 (r227481) +++ head/etc/periodic/daily/310.accounting Sun Nov 13 03:01:58 2011 (r227482) @@ -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;;