xref: /dragonfly/etc/rc.d/accounting (revision 9bb2a92d)
1#!/bin/sh
2#
3# $NetBSD: accounting,v 1.7 2002/03/22 04:33:57 thorpej Exp $
4# $FreeBSD: src/etc/rc.d/accounting,v 1.4 2002/10/12 10:31:31 schweikh Exp $
5# $DragonFly: src/etc/rc.d/accounting,v 1.3 2004/01/26 17:21:15 rob Exp $
6#
7
8# PROVIDE: accounting
9# REQUIRE: mountall
10# BEFORE: DAEMON
11# KEYWORD: DragonFly
12
13. /etc/rc.subr
14
15name="accounting"
16rcvar=`set_rcvar`
17accounting_command="/usr/sbin/accton"
18accounting_file="/var/account/acct"
19start_cmd="accounting_start"
20stop_cmd="accounting_stop"
21
22accounting_start()
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	echo "Turning on accounting."
35	${accounting_command} ${accounting_file}
36}
37
38accounting_stop()
39{
40	echo "Turning off accounting."
41	${accounting_command}
42}
43
44load_rc_config $name
45run_rc_command "$1"
46