#!/bin/bash

TMP=/tmp/config-firewall.$$
rm -f $TMP && touch $TMP

trap "rm $TMP* 2>/dev/null" EXIT

ifconfig -a | sed -ne 's/^[ 	]*inet addr:\([^ 	]*\).*$/\1/p' | \
while read addr; do
  cat >>$TMP <<EOF
-A INPUT -s $addr -p tcp -m tcp --dport 80 -j ACCEPT
EOF
done

cp -p /etc/sysconfig/iptables /etc/sysconfig/iptables~

sed -e '/^%%ACCEPT_RULES%%$/ { 
r '$TMP'
d
}' configfiles/iptables.in > /etc/sysconfig/iptables.

exit $?
