#!/bin/sh
set -e

#  if [ "$1" = remove ] && grep -q "#-- smtp-refuser begin" /etc/hosts.allow; then
#  	TMPFILE=`tempfile`
#  	sed -e '/#-- smtp-refuser begin/,/#-- smtp-refuser end/d' < /etc/hosts.allow > $TMPFILE
#  	mv $TMPFILE /etc/hosts.allow
#  fi

# I consider the above a bit dangerous; administrator may have edited
# /etc/hosts.allow and inserted other, non-smtp-refuser rules in
# that range.  So we let the admin know to do it with an editor:

if grep -q -i 'smtp-refuser' /etc/hosts.allow; then
    echo "WARNING: Your /etc/hosts.allow appears to still contain" ;
    echo "some smtp-refuser rules." ;
    echo ;
    echo "Please edit /etc/hosts.allow and remove the rules that pass" ;
    echo "connections to the (no-longer existent) smtp-refuser." ;
    echo ;
    echo "Press a key to continue..." ;
    read REPLY
fi

if [ "$1" = purge ]; then
	rm -f /etc/smtp-refuser.conf
fi

#DEBHELPER#
