#!/bin/bash
#
# DWall        Dwall firewall
#
# chkconfig:    2345 76 24
# description:  Dwall firewall
# processname:  dwall
# config:       /etc/dwall/dwall.conf
# pidfile: /var/run/dwall
#
# Written by Dag Wieers <dag@wieers.com>.
# Rewritten for ALTLinux by Mikhail Pokidko <pma@altlinux.org>
# Some fixes for ALTLinux by Denis Medvedev <nbr@altlinux.org>
#
# chkconfig: - 09 91
# description: Dwall firewall
#

WITHOUT_RC_COMPAT=1

. /etc/init.d/functions

SourceIfNotEmpty /etc/sysconfig/network

DAEMON=/usr/bin/dwall
PIDFILE=/var/run/dwall.pid
LOCKFILE=/var/lock/dwall
RETVAL=0

start()
{
    echo "y" | $DAEMON 
    return $RETVAL
}
			
stop()
{
    echo -n $"Shutting down $desc ($prog): "
    iptables -F
    iptables -X
    iptables -P INPUT ACCEPT
    iptables -P FORWARD DROP
    iptables -P OUTPUT ACCEPT
    success
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
    return $RETVAL
}

restart()
{
    stop
    start
}
			
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|reload)
	restart
	;;
  condrestart)
	[ -e /var/lock/subsys/$prog ] && restart
	RETVAL=$?
	;;
  status)
	status $prog
	RETVAL=$?
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|condrestart|status}"
	RETVAL=1
esac

exit $RETVAL
