#!/bin/sh
#
# shorewall		The Shoreline Firewall (Shorewall) Packet Filtering Firewall
#
# chkconfig:	2345 10 89
#
# description: Packet filtering firewall
#

# Source function library
. /etc/rc.d/init.d/functions
. /usr/share/shorewall/functions

# Get network config
. /etc/sysconfig/network

# Check that networking is up
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network ]; then
		msg_network_down shorewall
		exit 1
	fi
else
	exit 0
fi

start() {
	if [ -f /var/lock/subsys/shorewall ]; then
		msg_already_running shorewall
		return
	fi

	msg_starting "Shorewall"
	busy
	/usr/sbin/shorewall -q start >/dev/null
	RETVAL=$?
	if [ $RETVAL -eq 0 ]; then
		ok
		touch /var/lock/subsys/shorewall
        else
		fail
	fi
}

stop() {
	if [ ! -f /var/lock/subsys/shorewall ]; then
		msg_not_running shorewall
		return
	fi

	msg_stopping "Shorewall"
	busy
	/usr/sbin/shorewall stop >/dev/null
	RETVAL=$?
	if [ $RETVAL -eq 0 ]; then
		ok
		rm -f /var/lock/subsys/shorewall >/dev/null 2>&1
	else
		fail
	fi
}

# See how we were called
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	status shorewall
	exec /usr/sbin/shorewall status
	exit $?
	;;
  restart)
	stop
	start
	;;
  *)
 	msg_usage "$0 {start|stop|restart|status}"
	exit 3
esac
