#!/bin/sh
#	runfwscript 0.02
#
#	Copyright (C) 2000:	Manel Marin <manel3@apdo.com>
#	Licence:		GNU GPL version >= 2
#
#
#	Selecciona un script segn el soporte de filtrado del kernel
#
#	Uso:	runfwscript script
#	esto lanzar script-ipfwadm o script-ipchains o script-iptables
#	o dar un mensaje de error si no hay soporte de filtrado en el kernel
#
#		runfwscript -i script	#muestra el comando que se lanzara
#
#--------
#	Selects a script depending on the kernel packet filter support
#
#	Use:	runfwscript script
#	this will run script-ipfwadm or script-ipchains or script-iptables
#	or echo an error message if there is no packetfilter support in kernel
#
#		runfwscript -i script	#shows command should be runned
#


if [ -e /proc/net/ip_input ]
then
    FW="ipfwadm"

elif [ -e /proc/net/ip_fwchains ]
then
    FW="ipchains"

# Si existe modulo iptables y monta/ya esta montado
# If module iptables exists and mounts/already mounted
elif insmod -p iptables > /dev/null 2>&1
then
    FW="iptables"

else
    echo "firewall-easy: No packet filter support detected in kernel" 1>&2
    exit
fi

if [ "$1" = "-i" ]
then
    shift			# Salto la opcin "-i"
    echo "firewall-easy: $FW support detected" 1>&2		# -> stderr
    echo "$1-$FW"		# Muestro comando que se lanzara
else
    $1-$FW			# Lanzo comando
fi
