7 # REQUIRE: mountcritremote
14 rcvar="accounting_enable"
15 accounting_command="/usr/sbin/accton"
16 accounting_file="/var/account/acct"
18 extra_commands="rotate_log"
20 start_cmd="accounting_start"
21 stop_cmd="accounting_stop"
22 rotate_log_cmd="accounting_rotate_log"
24 create_accounting_file()
26 install -o root -g wheel -m 0640 /dev/null "${accounting_file}"
33 _dir="${accounting_file%/*}"
34 if [ ! -d "$_dir" ]; then
35 if ! mkdir -p -m 0750 "$_dir"; then
36 err 1 "Could not create $_dir."
40 if [ ! -e "$accounting_file" ]; then
41 echo -n "Creating accounting file ${accounting_file}"
42 create_accounting_file
46 echo "Turning on accounting."
47 ${accounting_command} ${accounting_file}
52 echo "Turning off accounting."
56 accounting_rotate_log()
58 # Note that this function must handle being called as "onerotate_log"
59 # (by the periodic scripts) when accounting is disabled, and handle
60 # being called multiple times (by an admin making mistakes) without
61 # anything having actually rotated the old .0 file out of the way.
63 if [ -e "${accounting_file}.0" ]; then
64 err 1 "Cannot rotate accounting log, ${accounting_file}.0 already exists."
67 if [ ! -e "${accounting_file}" ]; then
68 err 1 "Cannot rotate accounting log, ${accounting_file} does not exist."
71 mv ${accounting_file} ${accounting_file}.0
73 if checkyesno accounting_enable; then
74 create_accounting_file
75 ${accounting_command} "${accounting_file}"