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