310.accounting revision 77492
1#!/bin/sh
2#
3# $FreeBSD: head/etc/periodic/daily/310.accounting 77492 2001-05-30 16:46:53Z brian $
4#
5
6# If there is a global system configuration file, suck it in.
7#
8if [ -r /etc/defaults/periodic.conf ]
9then
10    . /etc/defaults/periodic.conf
11    source_periodic_confs
12fi
13
14case "$daily_accounting_enable" in
15    [Yy][Ee][Ss])
16	if [ ! -f /var/account/acct ]
17	then
18	    echo '$daily_accounting_enable is set but /var/account/acct' \
19		"doesn't exist"
20	    rc=2
21	else
22	    echo ""
23	    echo "Rotating accounting logs and gathering statistics:"
24
25	    cd /var/account
26	    rc=0
27	
28	    n=$daily_accounting_save
29	    rm -f acct.$n.gz acct.$n || rc=3
30	    m=$n
31	    n=$(($n - 1))
32	    while [ $n -ge 0 ]
33	    do
34		[ -f acct.$n.gz ] && { mv -f acct.$n.gz acct.$m.gz || rc=3; }
35		[ -f acct.$n ] &&    { mv -f acct.$n acct.$m || rc=3; }
36		m=$n
37		n=$(($n - 1))
38	    done
39	    cp -pf acct acct.0 || rc=3
40	    sa -s $daily_accounting_flags || rc=3
41
42	    case "$daily_accounting_compress" in
43		[Yy][Ee][Ss])
44		    gzip -f acct.0 || rc=3;;
45	    esac
46	fi;;
47
48    *)  rc=0;;
49esac
50
51exit $rc
52