accounting revision 174438
1#!/bin/sh
2#
3# $FreeBSD: head/etc/rc.d/accounting 174438 2007-12-08 07:20:23Z dougb $
4#
5
6# PROVIDE: accounting
7# REQUIRE: mountcritremote
8# BEFORE: DAEMON
9# KEYWORD: nojail
10
11. /etc/rc.subr
12
13name="accounting"
14rcvar=`set_rcvar`
15accounting_command="/usr/sbin/accton"
16accounting_file="/var/account/acct"
17start_cmd="accounting_start"
18stop_cmd="accounting_stop"
19
20accounting_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
43accounting_stop()
44{
45	echo "Turning off accounting."
46	${accounting_command}
47}
48
49load_rc_config $name
50run_rc_command "$1"
51