2001-06-16 07:16:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2002-06-13 22:14:37 +00:00
|
|
|
# $NetBSD: accounting,v 1.7 2002/03/22 04:33:57 thorpej Exp $
|
|
|
|
# $FreeBSD$
|
2001-06-16 07:16:14 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: accounting
|
2004-03-05 07:43:38 +00:00
|
|
|
# REQUIRE: mountcritremote
|
2002-06-13 22:14:37 +00:00
|
|
|
# BEFORE: DAEMON
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2001-06-16 07:16:14 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="accounting"
|
2002-06-13 22:14:37 +00:00
|
|
|
rcvar=`set_rcvar`
|
|
|
|
accounting_command="/usr/sbin/accton"
|
|
|
|
accounting_file="/var/account/acct"
|
2001-06-16 07:16:14 +00:00
|
|
|
start_cmd="accounting_start"
|
|
|
|
stop_cmd="accounting_stop"
|
|
|
|
|
|
|
|
accounting_start()
|
|
|
|
{
|
2004-01-17 11:25:16 +00:00
|
|
|
_dir=`dirname "$accounting_file"`
|
|
|
|
if [ ! -d `dirname "$_dir"` ]; then
|
|
|
|
if ! mkdir -p "$_dir"; then
|
|
|
|
warn "Could not create $_dir."
|
|
|
|
return 1
|
2002-06-13 22:14:37 +00:00
|
|
|
fi
|
2004-01-17 11:25:16 +00:00
|
|
|
fi
|
|
|
|
if [ ! -e "$accounting_file" ]; then
|
|
|
|
touch "$accounting_file"
|
|
|
|
fi
|
2002-06-13 22:14:37 +00:00
|
|
|
|
|
|
|
if [ ! -f ${accounting_file} ]; then
|
|
|
|
echo "Creating accounting file ${accounting_file}"
|
|
|
|
( umask 022 ; > ${accounting_file} )
|
2001-06-16 07:16:14 +00:00
|
|
|
fi
|
2002-06-13 22:14:37 +00:00
|
|
|
echo "Turning on accounting."
|
|
|
|
${accounting_command} ${accounting_file}
|
2001-06-16 07:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
accounting_stop()
|
|
|
|
{
|
|
|
|
echo "Turning off accounting."
|
2002-06-13 22:14:37 +00:00
|
|
|
${accounting_command}
|
2001-06-16 07:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|