accounting revision 126636
178344Sobrien#!/bin/sh 278344Sobrien# 398184Sgordon# $NetBSD: accounting,v 1.7 2002/03/22 04:33:57 thorpej Exp $ 498184Sgordon# $FreeBSD: head/etc/rc.d/accounting 126636 2004-03-05 07:43:38Z mtm $ 578344Sobrien# 678344Sobrien 778344Sobrien# PROVIDE: accounting 8126636Smtm# REQUIRE: mountcritremote 998184Sgordon# BEFORE: DAEMON 10124616Smtm# KEYWORD: FreeBSD 1178344Sobrien 1278344Sobrien. /etc/rc.subr 1378344Sobrien 1478344Sobrienname="accounting" 1598184Sgordonrcvar=`set_rcvar` 1698184Sgordonaccounting_command="/usr/sbin/accton" 1798184Sgordonaccounting_file="/var/account/acct" 1878344Sobrienstart_cmd="accounting_start" 1978344Sobrienstop_cmd="accounting_stop" 2078344Sobrien 2178344Sobrienaccounting_start() 2278344Sobrien{ 23124627Smtm _dir=`dirname "$accounting_file"` 24124627Smtm if [ ! -d `dirname "$_dir"` ]; then 25124627Smtm if ! mkdir -p "$_dir"; then 26124627Smtm warn "Could not create $_dir." 27124627Smtm return 1 2898184Sgordon fi 29124627Smtm fi 30124627Smtm if [ ! -e "$accounting_file" ]; then 31124627Smtm touch "$accounting_file" 32124627Smtm fi 3398184Sgordon 3498184Sgordon if [ ! -f ${accounting_file} ]; then 3598184Sgordon echo "Creating accounting file ${accounting_file}" 3698184Sgordon ( umask 022 ; > ${accounting_file} ) 3778344Sobrien fi 3898184Sgordon echo "Turning on accounting." 3998184Sgordon ${accounting_command} ${accounting_file} 4078344Sobrien} 4178344Sobrien 4278344Sobrienaccounting_stop() 4378344Sobrien{ 4478344Sobrien echo "Turning off accounting." 4598184Sgordon ${accounting_command} 4678344Sobrien} 4778344Sobrien 4878344Sobrienload_rc_config $name 4978344Sobrienrun_rc_command "$1" 50