#! /bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/sbin/ipacset
CONFIG=/etc/ipac.conf
PROC=/proc/net/ip_acct
IPFWADM=/sbin/ipfwadm

# This file is a conffile and will be kept even if ipac is removed
# We need to check that the daemon, the config file, the /proc data
# and ipfwadm are all present.

test -f $DAEMON -a -f $CONFIG -a -f $PROC -a -f $IPFWADM || exit 0

case "$1" in
  start)
	echo -n Configuring IP accounting...
	$DAEMON
	echo done.
    ;;
  stop)
	echo -n Stopping IP accounting...
	fetchipac
	ipfwadm -A -f
	echo done.
    ;;
  restart | force-reload)
	echo -n Restarting IP accounting...
	fetchipac
	ipfwadm -A -f
	$DAEMON
	echo done.
	;;
  reload)
	exit 1
	;;
  *)
    echo "Usage: /etc/init.d/ipac {start|stop|restart|force-reload}"
    exit 1
    ;;
esac

exit 0
