#!/bin/sh
#
### BEGIN INIT INFO
# Provides:          mxallowd
# Required-Start:    $network $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: anti-spam daemon based on nolisting using iptables/libnetfilter
# Description:       mxallowd is a daemon for linux/netfilter(iptables) which
#                    uses nolisting (http://nolisting.org). That means, you define
#                    two MX-servers in your nameserver and mxallowd will block
#                    the access to any of these mailservers if the client did not
#                    try the other one. This blocks non-RFC-compliant mailservers,
#                    which are often in use by spammers and so-called direct-to-
#                    second-mx which is also a technique mainly used by spammers.
### END INIT INFO

[ $(id -ru) -eq 0 ] || { echo "You need to be root"; exit 1; }

. /lib/lsb/init-functions

case "$1" in
start)	log_daemon_msg "Starting anti-spam daemon" "mxallowd"
	start-stop-daemon --start --quiet --pidfile /var/run/mxallowd.pid --name mxallowd --startas /usr/sbin/mxallowd
	log_end_msg $?
	;;
stop)	log_daemon_msg "Stopping anti-spam daemon" "mxallowd"
	start-stop-daemon --stop --quiet --pidfile /var/run/mxallowd.pid --name mxallowd
	log_end_msg $?
	;;
restart|reload|force-reload)	log_daemon_msg "Restarting anti-spam daemon" "mxallowd"
	start-stop-daemon --stop --retry 5 --quiet --pidfile /var/run/mxallowd.pid --name mxallowd
	start-stop-daemon --start --quiet --pidfile /var/run/mxallowd.pid --name mxallowd --startas /usr/sbin/mxallowd
	log_end_msg $?
	;;
status)	status_of_proc -p /var/run/mxallowd.pid /usr/sbin/mxallowd mxallowd
	;;
*)	log_action_msg "Usage: $0 {start|stop|restart|reload|force-reload}"
	exit 2
	;;
esac
exit 0
