Author: dougb
Date: Thu Dec  1 05:47:51 2011
New Revision: 228166
URL: http://svn.freebsd.org/changeset/base/228166

Log:
  MFC r227482:
  
  The default setting, daily_accounting_compress="NO", was causing
  only 1 old file to be saved, so fix this.
  
  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.
  
  Approved by:  re (kensmith)

Modified:
  releng/9.0/etc/periodic/daily/310.accounting
Directory Properties:
  releng/9.0/etc/   (props changed)

Modified: releng/9.0/etc/periodic/daily/310.accounting
==============================================================================
--- releng/9.0/etc/periodic/daily/310.accounting        Thu Dec  1 05:46:25 
2011        (r228165)
+++ releng/9.0/etc/periodic/daily/310.accounting        Thu Dec  1 05:47:51 
2011        (r228166)
@@ -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;;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to