MFC: Use humanize_number(3) for -h and -H.
[dragonfly.git] / etc / periodic / daily / 310.accounting
blobb7ff5705f9b9959550e96212aba9e35ad8bbef3c
1 #!/bin/sh
3 # $FreeBSD: src/etc/periodic/daily/310.accounting,v 1.3.2.3 2001/06/13 19:36:50 brian Exp $
4 # $DragonFly: src/etc/periodic/daily/310.accounting,v 1.2 2003/06/17 04:24:48 dillon Exp $
7 # If there is a global system configuration file, suck it in.
9 if [ -r /etc/defaults/periodic.conf ]
10 then
11 . /etc/defaults/periodic.conf
12 source_periodic_confs
15 case "$daily_accounting_enable" in
16 [Yy][Ee][Ss])
17 if [ ! -f /var/account/acct ]
18 then
19 echo '$daily_accounting_enable is set but /var/account/acct' \
20 "doesn't exist"
21 rc=2
22 elif [ -z "$daily_accounting_save" ]
23 then
24 echo '$daily_accounting_enable is set but ' \
25 '$daily_accounting_save is not'
26 rc=2
27 else
28 echo ""
29 echo "Rotating accounting logs and gathering statistics:"
31 cd /var/account
32 rc=0
34 n=$daily_accounting_save
35 rm -f acct.$n.gz acct.$n || rc=3
36 m=$n
37 n=$(($n - 1))
38 while [ $n -ge 0 ]
40 [ -f acct.$n.gz ] && { mv -f acct.$n.gz acct.$m.gz || rc=3; }
41 [ -f acct.$n ] && { mv -f acct.$n acct.$m || rc=3; }
42 m=$n
43 n=$(($n - 1))
44 done
45 cp -pf acct acct.0 || rc=3
46 sa -s $daily_accounting_flags || rc=3
48 case "$daily_accounting_compress" in
49 [Yy][Ee][Ss])
50 gzip -f acct.0 || rc=3;;
51 esac
52 fi;;
54 *) rc=0;;
55 esac
57 exit $rc