#! /bin/sh
# Copyright (c) 2000-2002 SuSE GmbH Nuernberg, Germany.
#
# Author: Marc Heuse <marc@suse.de>
#
# /etc/init.d/SuSEfirewall2_final
#
### BEGIN INIT INFO
# Provides: SuSEfirewall2_final
# Required-Start: SuSEfirewall2_setup 
# X-UnitedLinux-Should-Start: $ALL $portmap ipsec named dhcpd
# Required-Stop: SuSEfirewall2_setup
# X-UnitedLinux-Should-Stop: $ALL
# Default-Start: 3 4 5
# Default-Stop: 
# Short-Description: SuSEfirewall2 phase 3
# Description: SuSEfirewall2_final does finally set all the firewalling
#	rules. Phase 3 of 3 of SuSEfirewall setup.
### END INIT INFO

SUSEFWALL="/sbin/SuSEfirewall2"

test -x $SUSEFWALL || exit 5
test -r /etc/sysconfig/SuSEfirewall2 || exit 6

. /etc/rc.status
rc_reset

case "$1" in
    start)
	echo -n "Starting Firewall Initialization "
	echo -n '(phase 3 of 3) '
	$SUSEFWALL start
	rc_status -v
	;;
    stop)
	#echo -e "$0 is not for stopping SuSEfirewall2 - use \"SuSEfirewall2 stop\" or the SuSEfirewall2_setup script."
	;;
    restart|force-reload)
	$0 start
	rc_status
	;;
    try-restart|reload)
	($0 status) >/dev/null 2>&1 || exit 7
	$0 start
	rc_status
	;;
    restart2)
	# the restart2 argument is used by yast2 to not open any ports
	# while the filter rules are being rewritten.
	RLVL=`/sbin/runlevel | sed 's/. //'`
	if [ ! -e /etc/init.d/rc${RLVL}.d/S??SuSEfirewall2_final ]; then
		$SUSEFWALL stop > /dev/null 2>&1
	fi
	$SUSEFWALL start > /dev/null 2>&1
	;;
    status)
	echo "Checking the status of the Firewall "
	$SUSEFWALL status || rc_failed 3
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart|reload|force-reload}"
	exit 1
	;;
esac

# Set exit status
rc_exit
