#!/bin/sh
#
#   $SERVER	Name of the service (eg. Apache, Postgres) 
#   $APPS	Name of the binary (or binaries) file, used to get the pid
#   $CMDLINE	Fully command line to run 
#   $ROOT	Path of the binary or base directory of aplication
#   Services that don't need a bin file don't use . diamond

SERVER="ip forwarding"
APPS=""
ROOT="/proc/sys/net/ipv4/ip_forward" 
CMDLINE=""
# this firewall only requires two options to start it up. The first
# is the incoming interface to the internet and the second is the
# outgoing interface to the internal network.So if you are connected
# to the internet via ppp then ppp0 will be incoming, if by cable or
# ethernet then eth0 will be the interface. Generally the outgoing
# interface will be eth1 unless you have some other interface like
# plip. So just enter the two interfaces in the OPTS= line below,
# the defaults are eth0 eth1.
OPTS="eth0 eth1" 

case "$1" in
	
	start)
		if [ -f $ROOT ]; then
    			echo "Activating ip forwarding..."
    			echo 1 > $ROOT
			echo "Starting the firewall....."
			/sbin/firewall.sh $OPTS &>/dev/null
 		 else
		 	echo "No support for $SERVER in Kernel"
		fi
	;;
	
	stop)
    		echo "Disabling ip forwarding........."
    		echo 0 >  $ROOT
	;;
	
	status)	
		TMP=`cat $ROOT`
		if [ "$TMP" == "0" ]; then
			echo -e "$SERVER \t is not active"
		else
			echo -e "$SERVER \t is active"
		fi
	;;
	
	*)
		echo "Usage {start|stop|status}"
	;;
esac
exit 0

