#!/bin/bash

if [ "$1" == "start" ]; then
	if [ -e /etc/sysconfig/iptables ]; then
		source /etc/sysconfig/iptables
		if (( $forward == 1 )) ; then
			echo 1 > /proc/sys/net/ipv4/ip_forward
		fi
	fi
	if [ -e /etc/sysconfig/firewall ]; then
		/usr/sbin/iptables-restore < /etc/sysconfig/firewall
	fi
elif [ "$1" == "stop" ]; then
	echo 0 > /proc/sys/net/ipv4/ip_forward
	iptables -F && \
		iptables -P INPUT ACCEPT && \
		iptables -P FORWARD ACCEPT && \
		iptables -P OUTPUT ACCEPT
fi
