1997-08-16 17:04:02 +00:00
|
|
|
#!/bin/sh -
|
|
|
|
#
|
1999-08-27 23:37:10 +00:00
|
|
|
# $FreeBSD$
|
1997-08-16 17:04:02 +00:00
|
|
|
#
|
|
|
|
|
2000-06-23 01:18:31 +00:00
|
|
|
# If there is a global system configuration file, suck it in.
|
|
|
|
#
|
|
|
|
if [ -r /etc/defaults/periodic.conf ]
|
|
|
|
then
|
|
|
|
. /etc/defaults/periodic.conf
|
|
|
|
source_periodic_confs
|
|
|
|
fi
|
|
|
|
|
2002-05-17 14:05:08 +00:00
|
|
|
oldmask=$(umask)
|
|
|
|
umask 066
|
2000-06-23 01:18:31 +00:00
|
|
|
case "$monthly_accounting_enable" in
|
|
|
|
[Yy][Ee][Ss])
|
|
|
|
W=/var/log/wtmp
|
2001-11-20 15:01:24 +00:00
|
|
|
rc=0
|
|
|
|
remove=NO
|
2000-09-14 17:19:15 +00:00
|
|
|
if [ ! -f $W.0 ]
|
2000-06-23 01:18:31 +00:00
|
|
|
then
|
2001-11-20 15:01:24 +00:00
|
|
|
if [ -f $W.0.gz ]
|
|
|
|
then
|
|
|
|
remove=YES
|
|
|
|
zcat $W.0.gz > $W.0 || rc=1
|
2002-04-30 17:07:32 +00:00
|
|
|
elif [ -f $W.0.bz2 ]
|
|
|
|
then
|
|
|
|
remove=YES
|
|
|
|
bzcat $W.0.bz2 > $W.0 || rc=1
|
2001-11-20 15:01:24 +00:00
|
|
|
else
|
|
|
|
echo '$monthly_accounting_enable is set but' \
|
|
|
|
"$W.0 doesn't exist"
|
|
|
|
rc=2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ $rc -eq 0 ]
|
|
|
|
then
|
2000-09-14 17:19:15 +00:00
|
|
|
echo ""
|
|
|
|
echo "Doing login accounting:"
|
1998-02-09 11:36:43 +00:00
|
|
|
|
2000-09-14 17:19:15 +00:00
|
|
|
rc=$(ac -p -w $W.0 | sort -nr +1 | tee /dev/stderr | wc -l)
|
|
|
|
[ $rc -gt 0 ] && rc=1
|
2001-11-20 15:01:24 +00:00
|
|
|
fi
|
|
|
|
[ $remove = YES ] && rm -f $W.0;;
|
2000-09-14 17:19:15 +00:00
|
|
|
|
|
|
|
*) rc=0;;
|
2000-06-23 01:18:31 +00:00
|
|
|
esac
|
2000-09-14 17:19:15 +00:00
|
|
|
|
2002-05-17 14:05:08 +00:00
|
|
|
umask $oldmask
|
2000-09-14 17:19:15 +00:00
|
|
|
exit $rc
|