#! /bin/sh
#
# guidedog	Start/Stop guidedog advanced routing
#
# chkconfig: 345 60 40
# description: Guidedog advanced routing
# processname: guidedog

# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0

# See how we were called.
case "$1" in
  start)
	echo -n "Starting guidedog: "
	if [ -f /etc/rc.guidedog ]; then
	  /etc/rc.guidedog
    else
      echo "/etc/rc.guidedog not found. Doing nothing."
	fi
	echo_success
	echo
#	RETVAL=$?
	;;
  stop)
	echo -n "Stopping guidedog services: "
	if [ -f /etc/rc.guidedog ]; then
		/sbin/sysctl -w net.ipv4.ip_forward=0
        /sbin/iptables -t nat -F
        /sbin/iptables -t nat -X
        /sbin/iptables -t nat -P PREROUTING ACCEPT
        /sbin/iptables -t nat -P POSTROUTING ACCEPT
        /sbin/iptables -t nat -P OUTPUT ACCEPT
    else
      echo "/etc/rc.guidedog not found. Doing nothing."
	fi
	echo_success
	echo
#	RETVAL=$?
	;;
  restart|reload)
	$0 stop
	$0 start
	RETVAL=$?
	;;
  *)
	echo "Usage: guidedog {start|stop|restart|reload}"
	exit 1
esac

exit $RETVAL
