51c612a
#!/bin/sh
51c612a
# config: /etc/sysconfig/arptables
51c612a
51c612a
# Source 'em up
51c612a
. /etc/init.d/functions
51c612a
51c612a
ARPTABLES_CONFIG=/etc/sysconfig/arptables
51c612a
51c612a
start() {
51c612a
	if [ ! -x /usr/sbin/arptables ]; then
51c612a
		exit 4
51c612a
	fi
51c612a
51c612a
	# don't do squat if we don't have the config file
51c612a
	if [ -f $ARPTABLES_CONFIG ]; then
51c612a
		echo -n $"Applying arptables firewall rules: "
51c612a
		/usr/sbin/arptables-restore < $ARPTABLES_CONFIG && \
51c612a
			success || \
51c612a
			failure
51c612a
		echo
51c612a
		touch /var/lock/subsys/arptables
51c612a
	else
51c612a
		failure
51c612a
		echo
51c612a
		echo $"Configuration file /etc/sysconfig/arptables missing"
51c612a
		exit 6
51c612a
	fi
51c612a
}
51c612a
51c612a
stop() {
51c612a
	echo -n $"Removing user defined chains:"
51c612a
	arptables -X && success || failure
51c612a
	echo -n $"Flushing all chains:"
51c612a
	arptables -F && success || failure
51c612a
	echo -n $"Resetting built-in chains to the default ACCEPT policy:"
51c612a
	arptables -P INPUT ACCEPT && \
51c612a
		arptables -P OUTPUT ACCEPT && \
51c612a
		success || \
51c612a
		failure
51c612a
	echo
51c612a
	rm -f /var/lock/subsys/arptables
51c612a
}
51c612a
51c612a
case "$1" in
51c612a
start)
51c612a
	start
51c612a
	;;
51c612a
51c612a
stop)
51c612a
	stop
51c612a
	;;
51c612a
51c612a
restart|reload)
51c612a
	# "restart" is really just "start" as this isn't a daemon,
51c612a
	# and "start" clears any pre-defined rules anyway.
51c612a
	# This is really only here to make those who expect it happy
51c612a
	start
51c612a
	;;
51c612a
51c612a
condrestart|try-restart|force-reload)
51c612a
	[ -e /var/lock/subsys/arptables ] && start
51c612a
	;;
51c612a
51c612a
*)
51c612a
	exit 2
51c612a
esac
51c612a
51c612a
exit 0