#! /bin/sh
### BEGIN INIT INFO
# Provides:          firehol
# Required-Start:    $network $syslog
# Required-Stop:     $network 
# Default-Start:     2 3 4 5 
# Default-Stop:      0 1 6 
# Description: Starts firehol firewall configuration 
# short-description: firehol firewall configuration
### END INIT INFO

#includes lsb functions 
. /lib/lsb/init-functions

PATH=/sbin:/bin
NAME=firehol
DESC=Firewall

test -x /sbin/firehol || exit 0

set -e

[ -r /etc/default/firehol ] && . /etc/default/firehol

START_FIREHOL="$( echo $START_FIREHOL | /usr/bin/tr a-z A-Z)"

COMMAND="$1" 
test -n "$1" && shift

case "$COMMAND" in
  start)
  	
  	if [ "$START_FIREHOL" = "NO"  ]; then
		log_warning_msg "$DESC disabled via /etc/default/firehol"
		exit 0
	else 
		log_daemon_msg "Starting $DESC" "$NAME"
		/sbin/firehol start "$@" >/dev/null || log_end_msg 1
		log_end_msg 0
	fi
	;;
  stop)
	log_daemon_msg "Stopping $DESC" "$NAME"
	/sbin/firehol stop "$@" >/dev/null || log_end_msg 1
	log_end_msg 0
	;;
  helpme|wizard) 
  	log_daemon_msg  "Starting $NAME wizard" 1>&2 
	/sbin/firehol wizard
	;;
  restart|force-reload)
  	if [ "$START_FIREHOL" = "NO"  ]; then
		log_warning_msg "$DESC disabled via /etc/default/firehol"
		exit 0
	else 
		log_daemon_msg "Restarting $DESC configuration"
		/sbin/firehol restart "$@" >/dev/null || log_end_msg 1
		log_action_end_msg 0 
	fi
	;;
  *)
	N=/etc/init.d/$NAME
	log_action_msg "Usage: $N {start|stop|restart|force-reload} [<args>]" >&2
	exit 1
	;;
esac

exit 0
