#!/bin/sh
#
# $Id: service_restore_SuSEfirewall2,v 1.1 2007/05/14 14:56:33 gleissner Exp $
#
#
# Project     :  SCPM (System Configuration Profile Management)
# Module      :  SCPM Utilities
# File        :  service_restore_SuSEfirewall2
# Description :  Restores SuSEfirewall2 service
# Author      :  Joachim Gleissner <jg@suse.de>
#
# Copyright 2002-2007 SuSE Linux AG, SUSE Linux Products GmbH
#
# Released under the terms of the GNU General Public License
# (see file COPYRIGHT in project root directory).
#

test -z "$1" && { echo "no init script given" >&2 ; exit 1 ; }
test -z "$2" && { echo "no runlevels given" >&2 ; exit 1 ; }

. /etc/sysconfig/scpm || exit 1
. $LIBDIR/resource_types/service/common || exit 1

SERVICE=SuSEfirewall2_setup
test -f $INITD/$SCRIPT || { echo "no such file $INITD/$SCRIPT" >&2 ; exit 2 ; }

shift

while [ -n "$1" ]; do
    RL=$( echo ${1%:*} )
    ACTIVE=$( echo ${1#*:} )
    test "$ACTIVE" = "on" && RUNLEVELS="${RUNLEVELS}${RL}"
    shift
done

test -z "$RUNLEVELS" && RUNLEVELS="off"

# NOTE: this does not work with Red Hat chkconfig
/sbin/chkconfig -f $SERVICE $RUNLEVELS

# Set SuSEfirewall2 init script accordingly
if [ "$RUNLEVELS" = "off" ]; then
	/sbin/chkconfig -f SuSEfirewall2_init off
else
	/sbin/chkconfig -f SuSEfirewall2_init on
fi

exit 0
