#! /bin/sh
### BEGIN INIT INFO
# Provides:          invirt-iptables
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Invirt iptables rules
# Description:       
### END INIT INFO

NAME=invirt-iptables
DESC="Invirt iptables rules"
RULES=/usr/share/invirt-iptables/rules.d
PATH=/sbin:/usr/sbin:/bin:/usr/bin

dpkg -s "$NAME" >/dev/null 2>/dev/null || exit 0

. /lib/init/std-init.sh

do_start()
{
        echo 1 > /proc/sys/net/ipv4/ip_forward

        for table in $(sed -ne 's/^*//p' $(run-parts --list "$RULES")); do
            iptables -t "$table" -F
        done
	cat $(run-parts --list "$RULES") | iptables-restore -n
}

do_reload()
{
	do_start
}

do_stop()
{
	return 0
}

std_init "$1"