summaryrefslogtreecommitdiffstats
path: root/etc/periodic
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2001-11-20 15:01:24 +0000
committerbrian <brian@FreeBSD.org>2001-11-20 15:01:24 +0000
commitf0503f1783b780d851e2c5525b43357e62e54777 (patch)
tree408a1ffef629744930f5f4a221ef473cda4379ff /etc/periodic
parenta29d7f0fbb6e4f8bb41e2bb11d13930547e9f8c0 (diff)
downloadFreeBSD-src-f0503f1783b780d851e2c5525b43357e62e54777.zip
FreeBSD-src-f0503f1783b780d851e2c5525b43357e62e54777.tar.gz
Handle wtmp.0 being compressed
PR: 32113 Submitted by: Yar Tikhiy <yar@comp.chem.msu.su> MFC after: 1 week
Diffstat (limited to 'etc/periodic')
-rwxr-xr-xetc/periodic/monthly/200.accounting21
1 files changed, 16 insertions, 5 deletions
diff --git a/etc/periodic/monthly/200.accounting b/etc/periodic/monthly/200.accounting
index f808bbf..402c36d 100755
--- a/etc/periodic/monthly/200.accounting
+++ b/etc/periodic/monthly/200.accounting
@@ -14,18 +14,29 @@ fi
case "$monthly_accounting_enable" in
[Yy][Ee][Ss])
W=/var/log/wtmp
+ rc=0
+ remove=NO
if [ ! -f $W.0 ]
then
- echo '$monthly_accounting_enable is set but' \
- "$W.0 doesn't exist"
- rc=2
- else
+ if [ -f $W.0.gz ]
+ then
+ remove=YES
+ zcat $W.0.gz > $W.0 || rc=1
+ else
+ echo '$monthly_accounting_enable is set but' \
+ "$W.0 doesn't exist"
+ rc=2
+ fi
+ fi
+ if [ $rc -eq 0 ]
+ then
echo ""
echo "Doing login accounting:"
rc=$(ac -p -w $W.0 | sort -nr +1 | tee /dev/stderr | wc -l)
[ $rc -gt 0 ] && rc=1
- fi;;
+ fi
+ [ $remove = YES ] && rm -f $W.0;;
*) rc=0;;
esac
OpenPOWER on IntegriCloud