#! /bin/sh
#
# Start process accounting.

test -x /usr/sbin/accton || exit 0

case "$1" in
  start)
    /usr/sbin/accton /var/account/pacct 2>/dev/null
    rv=$?
    if [ $rv = 0 ]
    then
      echo "Started process accounting."
    elif [ $rv = 38 ]
    then
      echo "Process accounting not available on this system."
    elif [ $rv = 16 ]
    then
      echo "Process accounting already running on this system."
    else
      echo "Unknow error code $rv. Strange."
    fi
    ;;
  stop)
    /usr/sbin/accton 2>/dev/null
    if [ $? = 0 ]
    then
      echo "Stopped process accounting."
    else
      echo "Process accounting not available on this system."
    fi
    ;;
  *)
    echo "Usage: /etc/init.d/acct {start|stop}"
    exit 1
esac

exit 0
