#! /bin/bsh -x
# This is the monthly accounting script 
# for Linux PC-Farms, 11/23/98
#
#@(#)$Id: monacct,v 1.2 2000/11/03 20:37:45 jonest Exp $ 
#@(#)$Author: jonest $
#@(#)$Log: monacct,v $
#@(#)Revision 1.2  2000/11/03 20:37:45  jonest
#@(#)Updated monacct to rotate some files.
#@(#)
#@(#)Revision 1.1  2000/10/17 19:58:06  jonest
#@(#)Initial commit of the Fermi Linux Process Accounting.
#@(#)
#
_adm=/var/adm
_lib=/usr/lib/acct
_sum=${_adm}/acct/sum
_nite=${_adm}/acct/nite
_fiscal=${_adm}/acct/fiscal
_statefile=${_fiscal}/statefile
PATH=:/usr/lib/acct:/bin:/usr/bin:/etc
export PATH


#if test $# -ne 1; then
#	echo "usage: monacct fiscal-number"
#	exit
#fi

_period=${1-`date +%m`}
echo ${_period} > ${_statefile}

cd ${_adm}

#	"move summary tacct file to fiscal directory"
mv ${_sum}/tacct ${_fiscal}/tacct${_period}
echo MOVE > ${_statefile}

#	"delete the daily tacct files"
rm -f ${_sum}/tacct????
echo TACCT > ${_statefile}

# 	"delete the raw accounting files"
rm -f ${_nite}/spacct????
echo SPACCT > ${_statefile}

#	"rotating active log"
mv ${_fiscal}/active ${_fiscal}/o_active
touch ${_fiscal}/active
echo `date` > ${_fiscal}/active
echo ACTIVE > ${_statefile}

#	"add commands here to do any charging of fees, etc"
echo COMPLETE > ${_statefile}
exit
