#! /bin/sh
# Copyright (c) 2000-2002 SuSE GmbH Nuernberg, Germany.
#
# Author: Marc Heuse <marc@suse.de>
#
# /etc/init.d/SuSEfirewall2_setup
#
### BEGIN INIT INFO
# Provides: SuSEfirewall2_setup
# Required-Start: SuSEfirewall2_init $network $local_fs
# X-UnitedLinux-Should-Start: route dhclient named
# Required-Stop: $local_fs
# X-UnitedLinux-Should-Stop: 
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: SuSEfirewall2 phase 2
# Description: SuSEfirewall2_setup does some basic setup and is the
#	phase 2 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 2 of 3) '
	$SUSEFWALL start
	rc_status -v
	;;
    stop)
	echo -n "Shutting down the Firewall "
	test "$FW_STOP_KEEP_ROUTING_STATE" = "yes" || echo -n "(and disabling routing) "
	$SUSEFWALL stop > /dev/null 2>&1
	rc_status -v
	;;
    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_setup ]; then
		$SUSEFWALL stop > /dev/null 2>&1
	fi
	$SUSEFWALL start > /dev/null 2>&1
	;;
    long-status)
	echo "Checking the status of SuSEfirewall2 "
	$SUSEFWALL status || rc_failed 3
	;;
    status)
	echo -n "Checking the status of SuSEfirewall2 "
	iptables -L reject_func >/dev/null 2>&1 || rc_failed 3
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart|reload|force-reload}"
	exit 1
	;;
esac

# Set exit status
rc_exit
