accounting revision 124616
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 124616 2004-01-17 10:16:38Z mtm $ 578344Sobrien# 678344Sobrien 778344Sobrien# PROVIDE: accounting 878344Sobrien# REQUIRE: mountall 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{ 23103019Sgordon case ${OSTYPE} in 2498184Sgordon FreeBSD) 2598184Sgordon _dir=`dirname "$accounting_file"` 2698184Sgordon if [ ! -d `dirname "$_dir"` ]; then 27104980Sschweikh if ! mkdir -p "$_dir"; then 2898184Sgordon warn "Could not create $_dir." 2998184Sgordon return 1 3098184Sgordon fi 3198184Sgordon fi 3298184Sgordon if [ ! -e "$accounting_file" ]; then 3398184Sgordon touch "$accounting_file" 3498184Sgordon fi 3598184Sgordon ;; 3698184Sgordon *) 3798184Sgordon ;; 3898184Sgordon esac 3998184Sgordon 4098184Sgordon if [ ! -f ${accounting_file} ]; then 4198184Sgordon echo "Creating accounting file ${accounting_file}" 4298184Sgordon ( umask 022 ; > ${accounting_file} ) 4378344Sobrien fi 4498184Sgordon echo "Turning on accounting." 4598184Sgordon ${accounting_command} ${accounting_file} 4678344Sobrien} 4778344Sobrien 4878344Sobrienaccounting_stop() 4978344Sobrien{ 5078344Sobrien echo "Turning off accounting." 5198184Sgordon ${accounting_command} 5278344Sobrien} 5378344Sobrien 5478344Sobrienload_rc_config $name 5578344Sobrienrun_rc_command "$1" 56