#!/bin/sh

. /etc/rc.conf

case $1 in
autostart)
	test x"${firewall:-NO}" = x"NO" && exit 0
	exec $0 start
	;;
start)
	. /etc/firewall.conf
	;;
stop)
	### Clear tables
	iptables -F
	iptables -X
	iptables -t nat -F
	iptables -t nat -X
	iptables -P INPUT ACCEPT
	iptables -P FORWARD ACCEPT
	iptables -P OUTPUT ACCEPT
	iptables -t nat -P PREROUTING ACCEPT
	iptables -t nat -P POSTROUTING ACCEPT
	;;
restart)
	$0 stop
	$0 start
	;;
*)
	echo "Usage: $0 {start | stop | restart}"
	;;
esac
exit $?
