#!/sbin/sh 
#
# @(#) $Revision: 72.5 $
#
#           Copyright (C) 1993 Hewlett-Packard Company
#                      ALL RIGHTS RESERVED.
#
# NOTE:    This script is not configurable!  Any changes made to this
#          script will be overwritten when you upgrade to the next
#          release of HP-UX.
#
# Descr:
#    This script will start or stop process accounting.
#
# Args:
#    start     : start up process accounting
#    stop      : stop process accounting
#    start_msg : only print message indicating what 'start' action does
#    stop_msg  : only print message indicating what 'stop' action does
#
# External Influences:
#    The environment variable START_ACCT can control the behavior of the
#    'start' action.  If it is not set or set to anything but "1", then
#    the 'start' action will be skipped.
#
# Return Values:
#    0 : successfull completion of task
#    1 : failure to complete task
#    2 : request was to start, but did not start process accounting
#        because control variable, START_ACCT, was not set to one.

PATH=/usr/sbin/acct:/usr/sbin:/usr/bin:/sbin
export PATH

rval=0

if [ -f /etc/rc.config ] 
then
    . /etc/rc.config
else
    echo "ERROR: /etc/rc.config defaults file MISSING"
    exit 1
fi

case "$1" in
start_msg)
    echo "Start accounting"
    ;;

stop_msg)
    echo "Stop accounting"
    ;;

'start')
    if [ "$START_ACCT" -eq 1 ]
    then
		/usr/sbin/acct/startup

		if [ $? -eq 0 ] 
		then
			echo "Accounting started"
		else
			echo "Unable to start accounting"
			rval=1
		fi
    else
		# skip activation of process accounting
		rval=2
    fi
    ;;

'stop')
    if [ "$START_ACCT" -eq 1 ]
    then
		/usr/sbin/acct/shutacct

		if [ $? -eq 0 ] 
		then
			echo "Accounting stopped"
		else
			echo "Unable to stop accounting"
			rval=1
		fi
	else
		# skip termination of process accounting
		rval=2
	fi
    ;;

*)
    echo "usage: $0 {start|stop|start_msg|stop_msg}"
    rval=1
    ;;
esac

exit $rval
