ee9336d9b7
PR: 37529 Partially submitted by: Peter Hollaubek <fifteen@inext.hu> MFC after: 1 week
49 lines
811 B
Bash
Executable File
49 lines
811 B
Bash
Executable File
#!/bin/sh -
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# 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
|
|
|
|
case "$monthly_accounting_enable" in
|
|
[Yy][Ee][Ss])
|
|
W=/var/log/wtmp
|
|
rc=0
|
|
remove=NO
|
|
if [ ! -f $W.0 ]
|
|
then
|
|
if [ -f $W.0.gz ]
|
|
then
|
|
remove=YES
|
|
zcat $W.0.gz > $W.0 || rc=1
|
|
elif [ -f $W.0.bz2 ]
|
|
then
|
|
remove=YES
|
|
bzcat $W.0.bz2 > $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
|
|
[ $remove = YES ] && rm -f $W.0;;
|
|
|
|
*) rc=0;;
|
|
esac
|
|
|
|
exit $rc
|