#!/bin/sh
#
# shorewall-lite	Shoreline Firewall is a high-level tool for configuring Netfilter.
#
# chkconfig: 2345 24 76
#
# config:       /etc/shorewall-lite/shorewall-lite.conf
# description: Shoreline Firewall is a high-level tool for configuring Netfilter.

# Do not load RH compatibility interface. 
WITHOUT_RC_COMPAT=1

# Source function library. 
. /etc/init.d/functions

# Source networking configuration. 
SourceIfNotEmpty /etc/sysconfig/network

EXEC=/sbin/shorewall-lite
LOCKFILE=/var/lock/subsys/shorewall-lite
RETVAL=0


start() {
        is_yes "$NETWORKING" || return 0
        action $"Applying Shorewall firewall rules:" "$EXEC" -f start 
	RETVAL=$?
        [ $RETVAL -eq 0 ] && touch "$LOCKFILE"
	return $RETVAL
}

stop() {
        action $"Applying Shorewall firewall rules:" "$EXEC" stop 
        RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
	return $RETVAL
}

restart() {
	action $"Restarting Shorewall firewall rules: " "$EXEC" restart 
        RETVAL=$?
	return $RETVAL
}

clear() {
	action $"Clearing Shorewall firewall rules: " "$EXEC" clear 
	RETVAL=$?
	return $RETVAL
}

RETVAL=0

# See how we were called.
case "$1" in
	start)
	    start
	    ;;
	stop)
	    stop
	    ;;
	restart)
	    restart
	    ;;
	reload)
	    restart
	    ;;
	clear)
	    clear
	    ;;
	condrestart)
	    if [ -e "$LOCKFILE" ]; then
		restart
	    fi
	    ;;
	condreload)
	    if [ -e "$LOCKFILE" ]; then
		restart
	    fi
	    ;;
	condstop)
	    if [ -e "$LOCKFILE" ]; then
		stop
	    fi
	;;
	status)
	    "$EXEC" status
	     RETVAL=$?
	    ;;
	*)
	    echo $"Usage: ${0##*/}  {start|stop|restart|reload|clear|condrestart|condstop|status}"
	    RETVAL=1
esac

exit $RETVAL
