]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - etc/rc.d/accounting
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / etc / rc.d / accounting
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: accounting
7 # REQUIRE: mountcritremote
8 # BEFORE: DAEMON
9 # KEYWORD: nojail
10
11 . /etc/rc.subr
12
13 name="accounting"
14 rcvar=`set_rcvar`
15 accounting_command="/usr/sbin/accton"
16 accounting_file="/var/account/acct"
17 start_cmd="accounting_start"
18 stop_cmd="accounting_stop"
19
20 accounting_start()
21 {
22         local _dir
23
24         _dir=`dirname "$accounting_file"`
25         if [ ! -d `dirname "$_dir"` ]; then
26                 if ! mkdir -p "$_dir"; then
27                         warn "Could not create $_dir."
28                         return 1
29                 fi
30         fi
31         if [ ! -e "$accounting_file" ]; then
32                 touch "$accounting_file"
33         fi
34
35         if [ ! -f ${accounting_file} ]; then
36                 echo "Creating accounting file ${accounting_file}"
37                 ( umask 022 ; > ${accounting_file} )
38         fi
39         echo "Turning on accounting."
40         ${accounting_command} ${accounting_file}
41 }
42
43 accounting_stop()
44 {
45         echo "Turning off accounting."
46         ${accounting_command}
47 }
48
49 load_rc_config $name
50 run_rc_command "$1"