1#!/bin/sh - 2# 3# $FreeBSD: src/etc/periodic/monthly/200.accounting,v 1.4.2.5 2002/05/21 03:17:08 brian Exp $ 4# $DragonFly: src/etc/periodic/monthly/200.accounting,v 1.2 2003/06/17 04:24:48 dillon Exp $ 5# 6 7# If there is a global system configuration file, suck it in. 8# 9if [ -r /etc/defaults/periodic.conf ] 10then 11 . /etc/defaults/periodic.conf 12 source_periodic_confs 13fi 14 15oldmask=$(umask) 16umask 066 17case "$monthly_accounting_enable" in 18 [Yy][Ee][Ss]) 19 W=/var/log/wtmp 20 rc=0 21 remove=NO 22 if [ ! -f $W.0 ] 23 then 24 if [ -f $W.0.gz ] 25 then 26 remove=YES 27 zcat $W.0.gz > $W.0 || rc=1 28 elif [ -f $W.0.bz2 ] 29 then 30 remove=YES 31 bzcat $W.0.bz2 > $W.0 || rc=1 32 else 33 echo '$monthly_accounting_enable is set but' \ 34 "$W.0 doesn't exist" 35 rc=2 36 fi 37 fi 38 if [ $rc -eq 0 ] 39 then 40 echo "" 41 echo "Doing login accounting:" 42 43 rc=$(ac -p -w $W.0 | sort -nr +1 | tee /dev/stderr | wc -l) 44 [ $rc -gt 0 ] && rc=1 45 fi 46 [ $remove = YES ] && rm -f $W.0;; 47 48 *) rc=0;; 49esac 50 51umask $oldmask 52exit $rc 53