#! /bin/sh
#
# Startup script for gpe firewall engine. 
# Based on debian skeleton.
#	

### BEGIN INIT INFO
# Provides:          gpe-shield
# Required-Start:    mountkernfs ifupdown $local_fs
# Required-Stop:     ifupdown $local_fs
# Should-Start:      
# Should-Stop:       
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: Start firewall at boot time
# Description:       Startup script for gpe firewall engine.
### END INIT INFO

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
GPE_SHIELD=/usr/bin/gpe-shield
IPTABLES=/sbin/iptables
NAME=gpe-shield
DESC="GPE desktop firewall"

SCRIPTNAME=/etc/init.d/$NAME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

# Read config file if it is present.
#if [ -r /etc/default/$NAME ]
#then
#	. /etc/default/$NAME
#fi

case "$1" in
  start)
	echo -n "Starting $DESC: $NAME"
	if [ -f /etc/gpe/gpe-shield-load ]
	then
		$GPE_SHIELD --activate
		echo " OK"
	else
		echo " deactivated"
	fi
	echo "."
	;;
	# for Debian - check this works!
  status)
	echo -n "Status of $DESC: $NAME"
	if [ -f /etc/gpe/gpe-shield-load ]
	then
		echo " OK"
	else
		echo " deactivated"
	fi
	echo "."
    ;;
  stop)
	echo -n "Stopping $DESC: $NAME"
	$IPTABLES --flush
	$IPTABLES -P INPUT ACCEPT
	echo "."
	;;
  restart|force-reload)
	#
	#	If the "reload" option is implemented, move the "force-reload"
	#	option to the "reload" entry above. If not, "force-reload" is
	#	just the same as "restart".
	#
	echo -n "Restarting $DESC: $NAME"
	echo "."
	;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
