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