#!/bin/sh
#
# firestarter	Firestarter firewall.
#
# chkconfig:	2345 11 89
#
# description:	Starts and stops FireStarter, an easy-to-use,
#       yet powerful, Linux firewall tool for GNOME.
#
# $Id: firestarter.init,v 1.5 2010/03/01 11:26:38 glen Exp $

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

# Get network config
. /etc/sysconfig/network

FS_CONTROL=/etc/firestarter/firestarter.sh

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

start() {
	# Check if the service is already running?
	if [ -f /var/lock/subsys/firestarter ]; then
		msg_already_running "firestarter"
		return
	fi

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

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

	msg_stopping "firestarter"
	busy
	$FS_CONTROL stop > /dev/null
	rm -f /var/lock/subsys/firestarter
	ok
}

condrestart() {
	if [ ! -f /var/lock/subsys/firestarter ]; then
		msg_not_running "firestarter"
		RETVAL=$1
		return
	fi

	stop
	start
}

# See how we were called.
case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart)
	stop
	start
	;;
  try-restart)
	condrestart 0
	;;
  force-reload)
	condrestart 7
	;;
  status)
	status firestarter
	RETVAL=$?
	;;
  *)
	msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
