Deleted Added
full compact
accounting (174438) accounting (218961)
1#!/bin/sh
2#
1#!/bin/sh
2#
3# $FreeBSD: head/etc/rc.d/accounting 174438 2007-12-08 07:20:23Z dougb $
3# $FreeBSD: head/etc/rc.d/accounting 218961 2011-02-22 21:13:40Z dougb $
4#
5
6# PROVIDE: accounting
7# REQUIRE: mountcritremote
8# BEFORE: DAEMON
9# KEYWORD: nojail
10
11. /etc/rc.subr
12
13name="accounting"
14rcvar=`set_rcvar`
15accounting_command="/usr/sbin/accton"
16accounting_file="/var/account/acct"
4#
5
6# PROVIDE: accounting
7# REQUIRE: mountcritremote
8# BEFORE: DAEMON
9# KEYWORD: nojail
10
11. /etc/rc.subr
12
13name="accounting"
14rcvar=`set_rcvar`
15accounting_command="/usr/sbin/accton"
16accounting_file="/var/account/acct"
17
18extra_commands="rotate_log"
19
17start_cmd="accounting_start"
18stop_cmd="accounting_stop"
20start_cmd="accounting_start"
21stop_cmd="accounting_stop"
22rotate_log_cmd="accounting_rotate_log"
19
20accounting_start()
21{
22 local _dir
23
23
24accounting_start()
25{
26 local _dir
27
24 _dir=`dirname "$accounting_file"`
25 if [ ! -d `dirname "$_dir"` ]; then
28 _dir="${accounting_file%/*}"
29 if [ ! -d "$_dir" ]; then
26 if ! mkdir -p "$_dir"; then
30 if ! mkdir -p "$_dir"; then
27 warn "Could not create $_dir."
28 return 1
31 err 1 "Could not create $_dir."
29 fi
30 fi
32 fi
33 fi
34
31 if [ ! -e "$accounting_file" ]; then
35 if [ ! -e "$accounting_file" ]; then
36 echo -n "Creating accounting file ${accounting_file}"
32 touch "$accounting_file"
37 touch "$accounting_file"
38 echo '.'
33 fi
39 fi
40 chmod 644 "$accounting_file"
34
41
35 if [ ! -f ${accounting_file} ]; then
36 echo "Creating accounting file ${accounting_file}"
37 ( umask 022 ; > ${accounting_file} )
38 fi
39 echo "Turning on accounting."
40 ${accounting_command} ${accounting_file}
41}
42
43accounting_stop()
44{
45 echo "Turning off accounting."
46 ${accounting_command}
47}
48
42 echo "Turning on accounting."
43 ${accounting_command} ${accounting_file}
44}
45
46accounting_stop()
47{
48 echo "Turning off accounting."
49 ${accounting_command}
50}
51
52accounting_rotate_log()
53{
54 local _dir _file
55
56 _dir="${accounting_file%/*}"
57 cd $_dir
58
59 if checkyesno accounting_enable; then
60 _file=`mktemp newacct-XXXXX`
61 ${accounting_command} ${_dir}/${_file}
62 fi
63
64 mv ${accounting_file} ${accounting_file}.0
65
66 if checkyesno accounting_enable; then
67 ln $_file ${accounting_file##*/}
68 ${accounting_command} ${accounting_file}
69 unlink $_file
70 fi
71}
72
49load_rc_config $name
50run_rc_command "$1"
73load_rc_config $name
74run_rc_command "$1"