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.1 2003/07/24 06:35:37 dillon Exp $ 6# 7 8# PROVIDE: accounting 9# REQUIRE: mountall 10# BEFORE: DAEMON 11# KEYWORD: DragonFly FreeBSD NetBSD 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 case ${OSTYPE} in 25 DragonFly) 26 _dir=`dirname "$accounting_file"` 27 if [ ! -d `dirname "$_dir"` ]; then 28 if ! mkdir -p "$_dir"; then 29 warn "Could not create $_dir." 30 return 1 31 fi 32 fi 33 if [ ! -e "$accounting_file" ]; then 34 touch "$accounting_file" 35 fi 36 ;; 37 FreeBSD) 38 _dir=`dirname "$accounting_file"` 39 if [ ! -d `dirname "$_dir"` ]; then 40 if ! mkdir -p "$_dir"; then 41 warn "Could not create $_dir." 42 return 1 43 fi 44 fi 45 if [ ! -e "$accounting_file" ]; then 46 touch "$accounting_file" 47 fi 48 ;; 49 50 51 *) 52 ;; 53 esac 54 55 if [ ! -f ${accounting_file} ]; then 56 echo "Creating accounting file ${accounting_file}" 57 ( umask 022 ; > ${accounting_file} ) 58 fi 59 echo "Turning on accounting." 60 ${accounting_command} ${accounting_file} 61} 62 63accounting_stop() 64{ 65 echo "Turning off accounting." 66 ${accounting_command} 67} 68 69load_rc_config $name 70run_rc_command "$1" 71