#!/bin/sh
#
# mason-firewall        Starts a Mason firewall.
#
#
# chkconfig: 2345 18 92
# description: mason-firewall starts the firewall created by the Mason \
# firewall builder.  As a firewall is important to system security, \
# it should be always turned on.

# Debian init script derived from original script by Jeff Licquia.

# Debian flags for runlevels - similar to RH's chkconfig.
FLAGS="defaults 19"

# Source function library.
if [ -f /etc/rc.d/init.d/functions ]; then
	. /etc/rc.d/init.d/functions
fi

MASONCONF=${MASONCONF:-"/etc/masonrc"}
[ -f $MASONCONF ] || exit 0

MASONLIB=${MASONLIB:-"/var/lib/mason/masonlib"}
if [ -f $MASONLIB ]; then
	. $MASONLIB
else
	echo Missing $MASONLIB library file.  Please get a complete copy of Mason from >/dev/stderr
	echo http://www.pobox.com/~wstearns/mason/ .  Exiting. >/dev/stderr
	exit
fi
if [ -f /etc/masonrc ]; then
	. /etc/masonrc
fi
checksys
checkconf

start () {
	if [ -f /var/lock/subsys/firewall ] ; then
		echo "You already have a firewall"
		exit 1
	else
		action "Starting Mason firewall: " runstandardfirewall
		touch /var/lock/subsys/firewall
	fi
	echo
}

stop () {
	echo -n "Shutting down Mason firewall: "
	action flushfirewall
	rm -f /var/lock/subsys/firewall
	echo
}
# See how we were called.
case "$1" in
  start)
		start
	;;
  
	stop)
		stop
	;;
  
	restart)
		stop
		start
	;;
  
	force-reload)
		stop
		start
	;;
  
	condrestart)
	if [ -f /var/lock/subsys/firewall ] ; then
		stop
		start
	fi
	;;
	*)
	
	echo "Usage: firewall {start|stop|restart|force-reload|condrestart}"
	exit 1
esac

exit 0

