#! /bin/sh
# Copyright (c) 2000-2002 SuSE GmbH Nuernberg, Germany.
#
# Author: Marc Heuse <marc@suse.de>
#
# /etc/init.d/SuSEfirewall2_init
#
### BEGIN INIT INFO
# Provides: SuSEfirewall2_init
# Required-Start:
# X-UnitedLinux-Should-Start: setserial
# Required-Stop: 
# X-UnitedLinux-Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: SuSEfirewall2 phase 1
# Description: SuSEfirewall2_init does some basic setup and is the
#	phase 1 of 3 of the SuSEfirewall initialization
### END INIT INFO
# X-SuSE-Dep-Only

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 1 of 3) '
	( $SUSEFWALL close ) > /dev/null 2>&1
	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_init ]; 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
