#!/bin/sh
#
# firewall        Starts a Mason firewall.
#
#
# chkconfig: 2345 18 92
# description: 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

MASONDIR=${MASONDIR:-"/var/lib/mason/"}
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


# See how we were called.
case "$1" in
  start)
	echo -n "Starting Mason firewall: "
	flushfirewall
	runfirewall STANDARD
	if [ -d /var/lock/subsys ]; then
		touch /var/lock/subsys/firewall
	fi
	echo
	;;
  stop)
	echo -n "Shutting down Mason firewall: "
	flushfirewall
	if [ -d /var/lock/subsys ]; then
		rm -f /var/lock/subsys/firewall
	fi
	echo
	;;
#  status)
#	status syslogd
#	status klogd
#	;;
  restart)
	$0 stop
	$0 start
	;;
  force-reload)
	$0 stop
	$0 start
	;;
  *)
	echo "Usage: $0 {start|stop|restart|force-reload}"
	exit 1
esac

exit 0

